Skip to content

Commit

Permalink
Update component screens (#89)
Browse files Browse the repository at this point in the history
Update component screens
  • Loading branch information
kodiakhq[bot] authored Dec 14, 2022
2 parents 1f2c52c + c2d0648 commit ba5a834
Show file tree
Hide file tree
Showing 32 changed files with 1,935 additions and 671 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
"@babel/runtime": "7.18.9",
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
"@types/react": "~18.0.24",
"@types/react-native": "~0.70.6",
"babel-loader": "8.2.5",
Expand Down
5 changes: 5 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const App = () => {
`flex-1 android:mt-[${StatusBar.currentHeight || 0}px]`,
)}
>
<StatusBar
translucent
backgroundColor={"transparent"}
barStyle="dark-content"
/>
<AdaptUIProvider>
<AppRoot />
</AdaptUIProvider>
Expand Down
2 changes: 1 addition & 1 deletion example/src/AppRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Drawer = createDrawerNavigator();

const AppRoot = () => {
return (
<Drawer.Navigator initialRouteName="SelectScreen">
<Drawer.Navigator initialRouteName="AvatarScreen">
<Drawer.Screen
options={{ title: "Avatar" }}
name="AvatarScreen"
Expand Down
35 changes: 35 additions & 0 deletions example/src/components/Group.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React, { PropsWithChildren } from "react";
import { ViewProps } from "react-native";
import {
Box,
styleAdapter,
Text,
useTheme,
} from "@adaptui/react-native-tailwind";

export interface GroupType extends ViewProps {
label: string;
}

export const Group = (props: PropsWithChildren<GroupType>) => {
const { children, label, style, ...other } = props;
const tailwind = useTheme();
return (
<Box
style={[
tailwind.style("bg-white-800 rounded-xl p-2 flex-col w-full"),
styleAdapter(style),
]}
{...other}
>
<Text style={tailwind.style("ml-3 font-bold")}>{label}</Text>
<Box
style={tailwind.style(
"flex flex-row flex-wrap justify-start items-center mt-2 ml-0",
)}
>
{children}
</Box>
</Box>
);
};
1 change: 1 addition & 0 deletions example/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Group";
132 changes: 96 additions & 36 deletions example/src/modules/feedback/CircularProgressScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import React from "react";
import React, { SetStateAction, useState } from "react";
import {
Box,
Button,
CircularProgress,
CircularProgressSizes,
CircularProgressTheme,
Radio,
RadioGroup,
Switch,
useTheme,
} from "@adaptui/react-native-tailwind";

import { Group } from "../../components";

const useCircularProgressState = (initialValue: number | null = 0) => {
const [value, setValue] = React.useState<number | null>(initialValue);

Expand Down Expand Up @@ -33,45 +40,98 @@ const useCircularProgressState = (initialValue: number | null = 0) => {

export const CircularProgressScreen = () => {
const tailwind = useTheme();
const [value, setValue] = useCircularProgressState();
const [progressValue, setProgressValue] = useCircularProgressState();
const [selectedTheme, setSelectedTheme] =
useState<CircularProgressTheme>("base");
const [selectedSize, setSelectedSize] = useState<CircularProgressSizes>("md");
const [hasHints, setHasHints] = useState<boolean>(false);
const [hasCustomTrack, setHasCustomTrack] = useState<boolean>(false);

return (
<Box
style={tailwind.style(
"flex-1 justify-center items-center px-2 bg-white-900",
)}
>
<Box style={tailwind.style("my-5")}>
<CircularProgress size="sm" />
</Box>
<Box style={tailwind.style("my-5")}>
<CircularProgress themeColor="primary" />
</Box>
<Box style={tailwind.style("my-5")}>
<CircularProgress
style={tailwind.style("w-48 h-48")}
themeColor="primary"
progressTrackColor={tailwind.getColor("text-green-600")}
/>
</Box>
<Box style={tailwind.style("my-5")}>
<CircularProgress size="lg" />
</Box>
<Box style={tailwind.style("my-5")}>
<CircularProgress value={value} themeColor="primary" size="xl" />
</Box>
<Box style={tailwind.style("my-5")}>
<Box style={tailwind.style("flex-1 justify-center bg-white-900")}>
<Box
style={tailwind.style(
"flex-1 px-2 justify-center items-center bg-white-900",
)}
>
<CircularProgress
hint={`${value}%`}
value={value}
themeColor="primary"
size="xl"
style={!hasCustomTrack ? null : tailwind.style("w-48 h-48")}
hint={!hasHints ? null : `${progressValue}%`}
value={progressValue}
themeColor={selectedTheme}
size={selectedSize}
progressTrackColor={
!hasCustomTrack ? null : tailwind.getColor("text-green-600")
}
/>
</Box>
<Box style={tailwind.style("flex-row justify-center w-full")}>
<Button onPress={() => setValue(0)}>Reset</Button>
<Button variant="ghost" onPress={() => setValue(null)}>
Make Indeterminate
</Button>
<Box
style={tailwind.style(
"rounded-t-lg shadow-lg bg-gray-100 justify-end p-2",
)}
>
<RadioGroup
value={selectedSize}
onChange={(value: CircularProgressSizes) => setSelectedSize(value)}
orientation="horizontal"
>
<Group label="Sizes">
<Radio value="sm" label="sm" />
<Radio value="md" label="md" />
<Radio value="lg" label="lg" />
<Radio value="xl" label="xl" />
</Group>
</RadioGroup>
<RadioGroup
value={selectedTheme}
onChange={(value: CircularProgressTheme) => setSelectedTheme(value)}
orientation="horizontal"
>
<Group label="Theme" style={tailwind.style("mt-2")}>
<Radio value="base" label="base" />
<Radio value="primary" label="primary" />
</Group>
</RadioGroup>
<Box
style={tailwind.style(
"flex flex-row justify-start flex-wrap w-full mt-2",
)}
>
<Switch
state={hasHints}
onStateChange={(value: SetStateAction<boolean>) => {
setHasHints(value);
setProgressValue(0);
}}
size="md"
label="Has Hints"
/>
<Switch
state={hasCustomTrack}
onStateChange={(value: SetStateAction<boolean>) =>
setHasCustomTrack(value)
}
size="md"
style={tailwind.style("ml-1")}
label="Custom track"
/>
</Box>
<Box
style={tailwind.style(
"flex flex-row justify-start flex-wrap w-full mt-2",
)}
>
<Button variant="solid" onPress={() => setProgressValue(0)}>
Reset
</Button>
<Button
variant="ghost"
onPress={() => setProgressValue(null)}
style={tailwind.style("ml-1")}
>
Make Indeterminate
</Button>
</Box>
</Box>
</Box>
);
Expand Down
122 changes: 101 additions & 21 deletions example/src/modules/feedback/MeterComponentScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,113 @@
import React from "react";
import { Box, Meter, useTheme } from "@adaptui/react-native-tailwind";
import React, { SetStateAction, useState } from "react";
import {
Box,
Meter,
MeterSizes,
MeterTheme,
Radio,
RadioGroup,
Switch,
useTheme,
} from "@adaptui/react-native-tailwind";

import { Group } from "../../components";

export const MeterComponentScreen = () => {
const tailwind = useTheme();
return (
<Box style={tailwind.style("flex-1 justify-center px-2 bg-white-900")}>
<Box style={tailwind.style("my-2")}>
<Meter intervals={3} value={0.55} />
</Box>
<Box style={tailwind.style("my-2")}>
<Meter themeColor="primary" intervals={3} value={0.85} />
</Box>
<Box style={tailwind.style("my-2")}>
<Meter themeColor="success" intervals={3} value={0.25} />
</Box>

<Box style={tailwind.style("my-2")}>
<Meter label="Stocks" themeColor="success" intervals={3} value={0.25} />
</Box>
const [selectedTheme, setSelectedTheme] = useState<MeterTheme>("base");
const [selectedSize, setSelectedSize] = useState<MeterSizes>("md");
const [hasFlatBorder, setHasFlatBorders] = useState<boolean>(false);
const [hasIntervals, setHasIntervals] = useState<boolean>(false);
const [hasHints, setHasHints] = useState<boolean>(false);
const [hasLabel, setHasLabel] = useState<boolean>(false);

<Box style={tailwind.style("my-2")}>
return (
<Box style={tailwind.style("flex-1 justify-center bg-white-900")}>
<Box
style={tailwind.style(
"flex-1 px-2 justify-center items-center bg-white-900",
)}
>
<Meter
label="Progress"
hint="1/3"
themeColor="primary"
intervals={3}
label={!hasLabel ? null : "Progress"}
hint={!hasHints ? null : "1/3"}
themeColor={selectedTheme}
intervals={!hasIntervals ? 1 : 3}
value={0.33}
size={selectedSize}
flatBorders={hasFlatBorder}
/>
</Box>
<Box
style={tailwind.style(
"rounded-t-lg shadow-lg bg-gray-100 justify-end p-2",
)}
>
<RadioGroup
value={selectedSize}
onChange={(value: MeterSizes) => setSelectedSize(value)}
orientation="horizontal"
>
<Group label="Sizes">
<Radio value="sm" label="sm" />
<Radio value="md" label="md" />
<Radio value="lg" label="lg" />
</Group>
</RadioGroup>
<RadioGroup
value={selectedTheme}
onChange={(value: MeterTheme) => setSelectedTheme(value)}
orientation="horizontal"
>
<Group label="Theme" style={tailwind.style("mt-2")}>
<Radio value="base" label="base" />
<Radio value="primary" label="primary" />
<Radio value="success" label="success" />
</Group>
</RadioGroup>
<Box
style={tailwind.style(
"flex flex-row justify-start flex-wrap w-full mt-2",
)}
>
<Switch
state={hasLabel}
onStateChange={(value: SetStateAction<boolean>) =>
setHasLabel(value)
}
size="md"
label="Label"
/>
<Switch
state={hasHints}
onStateChange={(value: SetStateAction<boolean>) =>
setHasHints(value)
}
size="md"
style={tailwind.style("ml-1")}
label="Hints"
/>
<Switch
state={hasIntervals}
onStateChange={(value: SetStateAction<boolean>) =>
setHasIntervals(value)
}
size="md"
style={tailwind.style("ml-1")}
label="Intervals"
/>
<Switch
state={hasFlatBorder}
onStateChange={(value: SetStateAction<boolean>) =>
setHasFlatBorders(value)
}
size="md"
style={tailwind.style("mt-1")}
label="Flat Borders"
/>
</Box>
</Box>
</Box>
);
};
Loading

0 comments on commit ba5a834

Please sign in to comment.