@jobber/components-native 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ import { useIntl } from "react-intl";
4
+ import { styles } from "./ProgressBar.style";
5
+ import { ProgressBarInner, calculateWidth } from "./ProgressBarInner";
6
+ import { messages } from "./messages";
7
+ import { tokens } from "../utils/design";
8
+ export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, }) {
9
+ const { formatMessage } = useIntl();
10
+ const accessibilityLabel = [];
11
+ accessibilityLabel.push(formatMessage(messages.complete, { current, total }));
12
+ inProgress &&
13
+ accessibilityLabel.push(formatMessage(messages.inProgress, { inProgress }));
14
+ return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: accessibilityLabel.join(", ") },
15
+ header,
16
+ React.createElement(View, { style: styles.progressBarContainer },
17
+ React.createElement(ProgressBarInner, { width: 100, animationDuration: 0, color: reverseTheme ? undefined : tokens["color-surface--background"] }),
18
+ !loading && (React.createElement(React.Fragment, null,
19
+ inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800 })) : (React.createElement(React.Fragment, null)),
20
+ React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 }))))));
21
+ }
@@ -0,0 +1,24 @@
1
+ import { StyleSheet } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+ export const styles = StyleSheet.create({
4
+ progressBarContainer: {
5
+ marginTop: tokens["space-small"],
6
+ marginBottom: tokens["space-small"],
7
+ height: 20,
8
+ position: "relative",
9
+ flexDirection: "row",
10
+ },
11
+ progressBarInner: {
12
+ backgroundColor: "rgba(255,255,255,0.3)",
13
+ width: "100%",
14
+ height: "100%",
15
+ position: "absolute",
16
+ left: 0,
17
+ top: 0,
18
+ borderRadius: 100,
19
+ },
20
+ progressInner: {
21
+ height: "100%",
22
+ borderRadius: 100,
23
+ },
24
+ });
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
3
+ // import Reanimated from "react-native-reanimated";
4
+ // import { useTiming } from "utils/reanimated";
5
+ import { styles } from "./ProgressBar.style";
6
+ export function ProgressBarInner({ width,
7
+ // animationDuration = 0,
8
+ color, }) {
9
+ // Animation breaking on Android
10
+ // const [animatedOpacity] = useTiming({
11
+ // duration: animationDuration,
12
+ // fromValue: 0,
13
+ // toValue: 1,
14
+ // });
15
+ return (React.createElement(View, { style: [
16
+ styles.progressBarInner,
17
+ Object.assign({ width: `${width}%` }, (color && { backgroundColor: color })),
18
+ ] }));
19
+ }
20
+ export function calculateWidth(total, current) {
21
+ if (total <= 0)
22
+ return 0;
23
+ if (current >= total)
24
+ return 100;
25
+ const curr = Math.max(0, current);
26
+ if (curr >= total)
27
+ return 100;
28
+ return (curr / total) * 100;
29
+ }
@@ -0,0 +1 @@
1
+ export { ProgressBar } from "./ProgressBar";
@@ -0,0 +1,13 @@
1
+ import { defineMessages } from "react-intl";
2
+ export const messages = defineMessages({
3
+ complete: {
4
+ id: "complete",
5
+ defaultMessage: "{current} of {total} complete",
6
+ description: "Progress bar accessibilityLabel for current/total",
7
+ },
8
+ inProgress: {
9
+ id: "inProgress",
10
+ defaultMessage: "{inProgress} in progress",
11
+ description: "Progress bar accessibilityLabel for inProgress/total",
12
+ },
13
+ });
@@ -0,0 +1 @@
1
+ export {};
package/dist/src/index.js CHANGED
@@ -11,5 +11,6 @@ export * from "./StatusLabel";
11
11
  export * from "./AtlantisContext";
12
12
  export * from "./Button";
13
13
  export * from "./InputFieldWrapper";
14
+ export * from "./ProgressBar";
14
15
  export * from "./Heading";
15
16
  export * from "./Chip";