@draftbit/core 48.1.1-4f642e.2 → 48.1.1-547afd.2
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.
- package/lib/src/components/AudioPlayer/AudioPlayerCommon.d.ts +39 -0
- package/lib/src/components/AudioPlayer/AudioPlayerCommon.js.map +1 -0
- package/lib/src/components/AudioPlayer/AudioPlayerWithInterface.d.ts +6 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.js +2 -2
- package/lib/src/components/AudioPlayer/AudioPlayerWithInterface.js.map +1 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/HeadlessAudioPlayer.d.ts +2 -3
- package/{src/components/MediaPlayer → lib/src/components}/AudioPlayer/HeadlessAudioPlayer.js +48 -9
- package/lib/src/components/AudioPlayer/HeadlessAudioPlayer.js.map +1 -0
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.d.ts +4 -5
- package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.js +1 -1
- package/lib/src/components/AudioPlayer/index.js.map +1 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.d.ts +6 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/lib/src/components/Progress/CircularProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/CircularProgress/index.js +14 -0
- package/lib/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/lib/src/components/Progress/IndeterminateProgress.d.ts +7 -0
- package/lib/src/components/Progress/IndeterminateProgress.js +39 -0
- package/lib/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.d.ts +6 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/LinearProgress/index.js +14 -0
- package/lib/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/lib/src/components/Progress/ProgressCommon.d.ts +40 -0
- package/lib/src/components/Progress/ProgressCommon.js +2 -0
- package/lib/src/components/Progress/ProgressCommon.js.map +1 -0
- package/lib/src/components/SwipeableItem/SwipeableItem.js +9 -2
- package/lib/src/components/SwipeableItem/SwipeableItem.js.map +1 -1
- package/lib/src/components/SwipeableItem/SwipeableItemCommon.d.ts +3 -2
- package/lib/src/components/SwipeableItem/SwipeableItemCommon.js.map +1 -1
- package/lib/src/index.d.ts +3 -2
- package/lib/src/index.js +3 -2
- package/lib/src/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/src/components/AudioPlayer/AudioPlayerCommon.ts +44 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.js +2 -2
- package/src/components/AudioPlayer/AudioPlayerWithInterface.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.tsx +9 -7
- package/{lib/src/components/MediaPlayer → src/components}/AudioPlayer/HeadlessAudioPlayer.js +48 -9
- package/src/components/AudioPlayer/HeadlessAudioPlayer.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/HeadlessAudioPlayer.tsx +64 -19
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.js +1 -1
- package/src/components/AudioPlayer/index.js.map +1 -0
- package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/index.tsx +4 -4
- package/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/src/components/Progress/CircularProgress/CircularProgress.tsx +200 -0
- package/src/components/Progress/CircularProgress/index.js +14 -0
- package/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/src/components/Progress/CircularProgress/index.tsx +28 -0
- package/src/components/Progress/IndeterminateProgress.js +39 -0
- package/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/src/components/Progress/IndeterminateProgress.tsx +74 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/src/components/Progress/LinearProgress/LinearProgress.tsx +132 -0
- package/src/components/Progress/LinearProgress/index.js +14 -0
- package/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/src/components/Progress/LinearProgress/index.tsx +25 -0
- package/src/components/Progress/ProgressCommon.js +2 -0
- package/src/components/Progress/ProgressCommon.js.map +1 -0
- package/src/components/Progress/ProgressCommon.ts +44 -0
- package/src/components/SwipeableItem/SwipeableItem.js +9 -2
- package/src/components/SwipeableItem/SwipeableItem.js.map +1 -1
- package/src/components/SwipeableItem/SwipeableItem.tsx +9 -1
- package/src/components/SwipeableItem/SwipeableItemCommon.js.map +1 -1
- package/src/components/SwipeableItem/SwipeableItemCommon.ts +3 -2
- package/src/index.js +3 -2
- package/src/index.js.map +1 -1
- package/src/index.tsx +3 -5
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.d.ts +0 -22
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.d.ts +0 -7
- package/lib/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +0 -1
- package/lib/src/components/MediaPlayer/AudioPlayer/index.js.map +0 -1
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.d.ts +0 -15
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.js +0 -32
- package/lib/src/components/MediaPlayer/MediaPlaybackWrapper.js.map +0 -1
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.d.ts +0 -21
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.js +0 -24
- package/lib/src/components/MediaPlayer/MediaPlayerCommon.js.map +0 -1
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.d.ts +0 -15
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +0 -69
- package/lib/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +0 -1
- package/lib/src/components/MediaPlayer/VideoPlayer/index.d.ts +0 -2
- package/lib/src/components/MediaPlayer/VideoPlayer/index.js +0 -2
- package/lib/src/components/MediaPlayer/VideoPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/AudioPlayerCommon.ts +0 -25
- package/src/components/MediaPlayer/AudioPlayer/AudioPlayerWithInterface.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/HeadlessAudioPlayer.js.map +0 -1
- package/src/components/MediaPlayer/AudioPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlaybackWrapper.js +0 -32
- package/src/components/MediaPlayer/MediaPlaybackWrapper.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlaybackWrapper.tsx +0 -56
- package/src/components/MediaPlayer/MediaPlayerCommon.js +0 -24
- package/src/components/MediaPlayer/MediaPlayerCommon.js.map +0 -1
- package/src/components/MediaPlayer/MediaPlayerCommon.ts +0 -50
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js +0 -69
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.js.map +0 -1
- package/src/components/MediaPlayer/VideoPlayer/VideoPlayer.tsx +0 -135
- package/src/components/MediaPlayer/VideoPlayer/index.js +0 -2
- package/src/components/MediaPlayer/VideoPlayer/index.js.map +0 -1
- package/src/components/MediaPlayer/VideoPlayer/index.ts +0 -2
- /package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js +0 -0
- /package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js +0 -0
- /package/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerCommon.js.map +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AVPlaybackSource } from "expo-av";
|
|
2
|
+
import { StyleProp, ViewStyle, TextStyle } from "react-native";
|
|
3
|
+
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
export declare type AudioInterruptionMode = "lower volume" | "stop";
|
|
5
|
+
export interface AudioPlayerStatus {
|
|
6
|
+
isPlaying: boolean;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isBuffering: boolean;
|
|
9
|
+
currentPositionMillis: number;
|
|
10
|
+
durationMillis: number;
|
|
11
|
+
bufferedDurationMillis: number;
|
|
12
|
+
isError: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HeadlessAudioPlayerRef {
|
|
16
|
+
seekToPosition: (positionMillis: number) => void;
|
|
17
|
+
togglePlayback: () => void;
|
|
18
|
+
}
|
|
19
|
+
export interface HeadlessAudioPlayerProps {
|
|
20
|
+
onPlaybackStatusUpdate?: (status: AudioPlayerStatus) => void;
|
|
21
|
+
onPlaybackFinish?: () => void;
|
|
22
|
+
source: AVPlaybackSource;
|
|
23
|
+
interruptionMode?: AudioInterruptionMode;
|
|
24
|
+
playsInBackground?: boolean;
|
|
25
|
+
playsInSilentModeIOS?: boolean;
|
|
26
|
+
playThroughEarpieceAndroid?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface AudioPlayerInterfaceProps {
|
|
29
|
+
style?: StyleProp<ViewStyle & TextStyle>;
|
|
30
|
+
thumbColor?: string;
|
|
31
|
+
completedTrackColor?: string;
|
|
32
|
+
remainingTrackColor?: string;
|
|
33
|
+
togglePlaybackIconSize?: number;
|
|
34
|
+
togglePlaybackIconColor?: string;
|
|
35
|
+
hidePlaybackIcon?: boolean;
|
|
36
|
+
hideDuration?: boolean;
|
|
37
|
+
hideSlider?: boolean;
|
|
38
|
+
theme: Theme;
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayerCommon.js","sourceRoot":"","sources":["../../../../src/components/AudioPlayer/AudioPlayerCommon.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AudioPlayerInterfaceProps, HeadlessAudioPlayerProps, HeadlessAudioPlayerRef } from "./AudioPlayerCommon";
|
|
3
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>, "theme"> & {
|
|
4
|
+
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
5
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>> & React.ForwardRefExoticComponent<AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>>, {}>;
|
|
6
|
+
export default _default;
|
package/lib/src/components/{MediaPlayer/AudioPlayer → AudioPlayer}/AudioPlayerWithInterface.js
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Text, View, StyleSheet } from "react-native";
|
|
3
3
|
import { AntDesign } from "@expo/vector-icons";
|
|
4
|
-
import { withTheme } from "
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
5
|
import Slider from "@react-native-community/slider";
|
|
6
6
|
import HeadlessAudioPlayer from "./HeadlessAudioPlayer";
|
|
7
|
-
import Pressable from "
|
|
7
|
+
import Pressable from "../Pressable";
|
|
8
8
|
/**
|
|
9
9
|
* Built on top of HeadlessAudioPlayer to provide a simple interface for playing audio
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayerWithInterface.js","sourceRoot":"","sources":["../../../../src/components/AudioPlayer/AudioPlayerWith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AAC,QAAQ,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAE7D,MAAM,aAAa,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,MAAM,eAAe,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/D,MAAM,eAAe,GAAG,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAE/D,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,aAAa,GAAG,GAAG,GAAG,eAAe,GAAG,GAAG,GAAG,eAAe,CAAC;KACtE;IAED,OAAO,eAAe,GAAG,GAAG,GAAG,eAAe,CAAC;AACjD,CAAC;AAED,eAAe,SAAS,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { HeadlessAudioPlayerProps } from "./AudioPlayerCommon";
|
|
3
|
-
import { MediaPlayerRef } from "../MediaPlayerCommon";
|
|
2
|
+
import { HeadlessAudioPlayerProps, HeadlessAudioPlayerRef } from "./AudioPlayerCommon";
|
|
4
3
|
/**
|
|
5
4
|
* Audio Player component without an interface (UI).
|
|
6
5
|
* Only handles playing of the audio and provides callbacks and ref functions
|
|
7
6
|
*/
|
|
8
|
-
declare const HeadlessAudioPlayer: React.ForwardRefExoticComponent<HeadlessAudioPlayerProps & React.RefAttributes<
|
|
7
|
+
declare const HeadlessAudioPlayer: React.ForwardRefExoticComponent<HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>>;
|
|
9
8
|
export default HeadlessAudioPlayer;
|
package/{src/components/MediaPlayer → lib/src/components}/AudioPlayer/HeadlessAudioPlayer.js
RENAMED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Audio, InterruptionModeIOS, InterruptionModeAndroid, } from "expo-av";
|
|
3
|
-
import { mapToMediaPlayerStatus } from "../MediaPlayerCommon";
|
|
4
|
-
import MediaPlaybackWrapper from "../MediaPlaybackWrapper";
|
|
5
3
|
/**
|
|
6
4
|
* Audio Player component without an interface (UI).
|
|
7
5
|
* Only handles playing of the audio and provides callbacks and ref functions
|
|
@@ -33,18 +31,33 @@ const HeadlessAudioPlayer = React.forwardRef(({ source, interruptionMode = "lowe
|
|
|
33
31
|
playThroughEarpieceAndroid,
|
|
34
32
|
]);
|
|
35
33
|
const onPlaybackStatusUpdate = (status) => {
|
|
36
|
-
const mappedStatus = mapToMediaPlayerStatus(status);
|
|
37
|
-
onPlaybackStatusUpdateProp === null || onPlaybackStatusUpdateProp === void 0 ? void 0 : onPlaybackStatusUpdateProp(mappedStatus);
|
|
38
34
|
if (status.isLoaded) {
|
|
35
|
+
onPlaybackStatusUpdateProp === null || onPlaybackStatusUpdateProp === void 0 ? void 0 : onPlaybackStatusUpdateProp({
|
|
36
|
+
isPlaying: status.isPlaying,
|
|
37
|
+
isLoading: false,
|
|
38
|
+
isBuffering: status.isBuffering,
|
|
39
|
+
currentPositionMillis: status.positionMillis || 0,
|
|
40
|
+
durationMillis: status.durationMillis || 0,
|
|
41
|
+
bufferedDurationMillis: status.playableDurationMillis || 0,
|
|
42
|
+
isError: false,
|
|
43
|
+
});
|
|
39
44
|
if (status.didJustFinish) {
|
|
40
45
|
onPlaybackFinish === null || onPlaybackFinish === void 0 ? void 0 : onPlaybackFinish();
|
|
41
46
|
}
|
|
42
47
|
setIsPlaying(status.isPlaying);
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
else if (status.error) {
|
|
50
|
+
onPlaybackStatusUpdateProp === null || onPlaybackStatusUpdateProp === void 0 ? void 0 : onPlaybackStatusUpdateProp({
|
|
51
|
+
isPlaying: false,
|
|
52
|
+
isLoading: false,
|
|
53
|
+
isBuffering: false,
|
|
54
|
+
currentPositionMillis: 0,
|
|
55
|
+
durationMillis: 0,
|
|
56
|
+
bufferedDurationMillis: 0,
|
|
57
|
+
isError: true,
|
|
58
|
+
error: status.error,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
48
61
|
};
|
|
49
62
|
const loadAudio = async () => {
|
|
50
63
|
onPlaybackStatusUpdateProp === null || onPlaybackStatusUpdateProp === void 0 ? void 0 : onPlaybackStatusUpdateProp({
|
|
@@ -60,11 +73,37 @@ const HeadlessAudioPlayer = React.forwardRef(({ source, interruptionMode = "lowe
|
|
|
60
73
|
setCurrentSound(sound);
|
|
61
74
|
sound.setOnPlaybackStatusUpdate(onPlaybackStatusUpdate);
|
|
62
75
|
};
|
|
76
|
+
const togglePlayback = React.useCallback(async () => {
|
|
77
|
+
//Has to be called everytime a player is played to reconfigure the global Audio config based on each player's configuration
|
|
78
|
+
await updateAudioMode();
|
|
79
|
+
if (isPlaying) {
|
|
80
|
+
await (currentSound === null || currentSound === void 0 ? void 0 : currentSound.pauseAsync());
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
await (currentSound === null || currentSound === void 0 ? void 0 : currentSound.playAsync());
|
|
84
|
+
}
|
|
85
|
+
}, [currentSound, updateAudioMode, isPlaying]);
|
|
86
|
+
const seekToPosition = React.useCallback(async (positionMillis) => {
|
|
87
|
+
await (currentSound === null || currentSound === void 0 ? void 0 : currentSound.setPositionAsync(positionMillis));
|
|
88
|
+
}, [currentSound]);
|
|
63
89
|
useSourceDeepCompareEffect(() => {
|
|
64
90
|
loadAudio();
|
|
65
91
|
// Ignore dependency of loadAudio
|
|
66
92
|
}, [source]);
|
|
67
|
-
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
return currentSound
|
|
95
|
+
? () => {
|
|
96
|
+
currentSound.unloadAsync();
|
|
97
|
+
}
|
|
98
|
+
: undefined;
|
|
99
|
+
}, [currentSound]);
|
|
100
|
+
React.useImperativeHandle(ref, () => {
|
|
101
|
+
return {
|
|
102
|
+
seekToPosition,
|
|
103
|
+
togglePlayback,
|
|
104
|
+
};
|
|
105
|
+
}, [seekToPosition, togglePlayback]);
|
|
106
|
+
return null;
|
|
68
107
|
});
|
|
69
108
|
// The source provided into the AudioPlayer can be of type {uri: "some uri"}
|
|
70
109
|
// In the case that this object is created inline, each rerender provides a new source object because a new object is initialized everytime
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadlessAudioPlayer.js","sourceRoot":"","sources":["../../../../src/components/AudioPlayer/HeadlessAudioPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,KAAK,EAEL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,SAAS,CAAC;AAMjB;;;GAGG;AACH,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAI1C,CACE,EACE,MAAM,EACN,gBAAgB,GAAG,cAAc,EACjC,iBAAiB,GAAG,KAAK,EACzB,oBAAoB,GAAG,KAAK,EAC5B,0BAA0B,GAAG,KAAK,EAClC,sBAAsB,EAAE,0BAA0B,EAClD,gBAAgB,GACjB,EACD,GAAG,EACH,EAAE;IACF,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAe,CAAC;IACtE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;QACnD,IAAI;YACF,MAAM,KAAK,CAAC,iBAAiB,CAAC;gBAC5B,uBAAuB,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AAO,CAAC;AACrB,CAAC;AAED,SAAS,0BAA0B,CACjC,QAA8B,EAC9B,YAAkC;IAElC,uDAAuD;IACvD,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { AudioPlayerInterfaceProps, HeadlessAudioPlayerProps } from "./AudioPlayerCommon";
|
|
3
|
-
import { MediaPlayerRef } from "../MediaPlayerCommon";
|
|
2
|
+
import { AudioPlayerInterfaceProps, HeadlessAudioPlayerProps, HeadlessAudioPlayerRef } from "./AudioPlayerCommon";
|
|
4
3
|
interface AudioPlayerProps {
|
|
5
4
|
mode?: "interface" | "headless";
|
|
6
5
|
}
|
|
7
|
-
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<AudioPlayerProps & AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<
|
|
6
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<AudioPlayerProps & AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>, "theme"> & {
|
|
8
7
|
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
9
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<AudioPlayerProps & AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<
|
|
8
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<AudioPlayerProps & AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>> & React.ForwardRefExoticComponent<AudioPlayerProps & AudioPlayerInterfaceProps & HeadlessAudioPlayerProps & React.RefAttributes<HeadlessAudioPlayerRef>>, {}>;
|
|
10
9
|
export default _default;
|
|
11
|
-
export {
|
|
10
|
+
export { HeadlessAudioPlayerRef as AudioPlayerRef } from "./AudioPlayerCommon";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { withTheme } from "
|
|
2
|
+
import { withTheme } from "../../theming";
|
|
3
3
|
import HeadlessAudioPlayer from "./HeadlessAudioPlayer";
|
|
4
4
|
import AudioPlayerWithInterface from "./AudioPlayerWithInterface";
|
|
5
5
|
const AudioPlayer = React.forwardRef(({ mode = "interface", ...rest }, ref) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/AudioPlayer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAMlE,MAAM,WAAW,GAAG,KAAK,CAAC,UAAU,CAGlC,CAAC,EAAE,IAAI,GAAG,WAAW,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;IACzC,QAAQ,IAAI,EAAE;QACZ,KAAK,UAAU;YACb,OAAO,oBAAC,mBAAmB,IAAC,GAAG,EAAE,GAAG,KAAM,IAAI,GAAI,CAAC;QACrD,KAAK,WAAW;YACd,gEAAgE;YAChE,OAAO,oBAAC,wBAAwB,IAAC,GAAG,EAAE,GAAG,KAAM,IAAI,GAAI,CAAC;KAC3D;AACH,CAAC,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PathProps } from "react-native-svg";
|
|
3
|
+
import Animated from "react-native-reanimated";
|
|
4
|
+
import { ValueProgressProps, CircularProgressProps } from "../ProgressCommon";
|
|
5
|
+
export declare const AnimatedPath: React.ComponentClass<Animated.AnimateProps<PathProps>, any>;
|
|
6
|
+
export declare const CircularProgress: React.FC<ValueProgressProps & CircularProgressProps>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Svg, { Path } from "react-native-svg";
|
|
3
|
+
import Animated, { useAnimatedProps, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
4
|
+
import { DEFAULT_ANIMATION_DURATION, } from "../ProgressCommon";
|
|
5
|
+
export const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
6
|
+
export const CircularProgress = ({ theme, minimumValue = 0, maximumValue = 100, value = minimumValue, thickness = 10, trackThickness = thickness, color = theme.colors.primary, trackColor = theme.colors.divider, trackOpacity = 1, showTrack = true, animationDuration = DEFAULT_ANIMATION_DURATION, isAnimated = true, lineCap = "round", trackLineCap = lineCap, dashWidth, trackDashWidth, dashGap, trackDashGap, dashOffset, trackDashOffset, customDashArray, trackCustomDashArray, onFullPathWidth, startPosition = "top", style, testID, }) => {
|
|
7
|
+
const [svgContainerWidth, setSvgContainerWidth] = React.useState(0);
|
|
8
|
+
const [circumfrence, setCircumefrence] = React.useState(0);
|
|
9
|
+
const dashArray = dashWidth !== undefined
|
|
10
|
+
? `${dashWidth} ${dashGap || dashWidth}`
|
|
11
|
+
: undefined;
|
|
12
|
+
const trackDashArray = trackDashWidth !== undefined
|
|
13
|
+
? `${trackDashWidth} ${trackDashGap || trackDashWidth}`
|
|
14
|
+
: undefined;
|
|
15
|
+
const maxThickness = Math.max(thickness, trackThickness);
|
|
16
|
+
const thicknessOffset = maxThickness / 2; // This offset guarantees nothing is cut off by view bounds
|
|
17
|
+
const radius = svgContainerWidth / 2;
|
|
18
|
+
const c = 2 * Math.PI * radius;
|
|
19
|
+
if (c !== circumfrence) {
|
|
20
|
+
setCircumefrence(c);
|
|
21
|
+
}
|
|
22
|
+
const startAngle = React.useMemo(() => {
|
|
23
|
+
switch (startPosition) {
|
|
24
|
+
case "top":
|
|
25
|
+
return 0;
|
|
26
|
+
case "right":
|
|
27
|
+
return 90;
|
|
28
|
+
case "bottom":
|
|
29
|
+
return 180;
|
|
30
|
+
case "left":
|
|
31
|
+
return 270;
|
|
32
|
+
}
|
|
33
|
+
}, [startPosition]);
|
|
34
|
+
const currentFillPercentage = value / (maximumValue + minimumValue);
|
|
35
|
+
const currentAngle = useSharedValue(startAngle + currentFillPercentage * 360);
|
|
36
|
+
const progressPathAnimatedProps = useAnimatedProps(() => {
|
|
37
|
+
const isBelowMinAngle = currentAngle.value <= startAngle;
|
|
38
|
+
return {
|
|
39
|
+
d: circlePath(radius, radius, radius - thicknessOffset, startAngle, Math.min(currentAngle.value, startAngle + 360) //Prevents going beyond the max angle
|
|
40
|
+
),
|
|
41
|
+
strokeOpacity: isBelowMinAngle ? 0.0 : 1.0,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
currentAngle.value = withTiming(startAngle + currentFillPercentage * 360, {
|
|
46
|
+
duration: isAnimated ? animationDuration : 0,
|
|
47
|
+
});
|
|
48
|
+
}, [
|
|
49
|
+
value,
|
|
50
|
+
currentFillPercentage,
|
|
51
|
+
animationDuration,
|
|
52
|
+
currentAngle,
|
|
53
|
+
maximumValue,
|
|
54
|
+
minimumValue,
|
|
55
|
+
isAnimated,
|
|
56
|
+
startAngle,
|
|
57
|
+
]);
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
onFullPathWidth === null || onFullPathWidth === void 0 ? void 0 : onFullPathWidth(circumfrence);
|
|
60
|
+
}, [circumfrence, onFullPathWidth]);
|
|
61
|
+
return (React.createElement(Svg, { testID: testID !== null && testID !== void 0 ? testID : "circular-progress-component", onLayout: (event) => {
|
|
62
|
+
const width = event.nativeEvent.layout.width;
|
|
63
|
+
setSvgContainerWidth(width);
|
|
64
|
+
}, style: [
|
|
65
|
+
{
|
|
66
|
+
height: svgContainerWidth,
|
|
67
|
+
},
|
|
68
|
+
style,
|
|
69
|
+
] },
|
|
70
|
+
showTrack && (React.createElement(Path, { d: circlePath(radius, radius, radius - thicknessOffset, startAngle, startAngle + 360), stroke: trackColor, strokeWidth: trackThickness, strokeOpacity: trackOpacity, strokeLinecap: trackLineCap, strokeDasharray: trackCustomDashArray || trackDashArray, strokeDashoffset: trackDashOffset })),
|
|
71
|
+
React.createElement(AnimatedPath, { animatedProps: progressPathAnimatedProps, stroke: color, strokeWidth: thickness, strokeLinecap: lineCap, strokeDasharray: customDashArray || dashArray, strokeDashoffset: dashOffset })));
|
|
72
|
+
};
|
|
73
|
+
// From: https://github.com/bartgryszko/react-native-circular-progress/blob/a93b501aea40306126c8ede72089741eead52308/src/CircularProgress.js#L15
|
|
74
|
+
function circlePath(x, y, radius, startAngle, endAngle) {
|
|
75
|
+
"worklet"; // Reanimated worklet to be runnable on the UI thread
|
|
76
|
+
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
|
77
|
+
var angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
|
78
|
+
return {
|
|
79
|
+
x: centerX + radius * Math.cos(angleInRadians),
|
|
80
|
+
y: centerY + radius * Math.sin(angleInRadians),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
var start = polarToCartesian(x, y, radius, endAngle * 0.9999);
|
|
84
|
+
var end = polarToCartesian(x, y, radius, startAngle);
|
|
85
|
+
var largeArcFlag = endAngle - startAngle <= 180 ? "0" : "1";
|
|
86
|
+
var d = [
|
|
87
|
+
"M",
|
|
88
|
+
start.x,
|
|
89
|
+
start.y,
|
|
90
|
+
"A",
|
|
91
|
+
radius,
|
|
92
|
+
radius,
|
|
93
|
+
0,
|
|
94
|
+
largeArcFlag,
|
|
95
|
+
0,
|
|
96
|
+
end.x,
|
|
97
|
+
end.y,
|
|
98
|
+
];
|
|
99
|
+
return d.join(" ");
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=CircularProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircularProgress.js","sourceRoot":"","sources":["../../../../../src/components/Progress/CircularProgress/CircularProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,EAAE,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAC;AACxD,OAAO,QAAQ,EAAE,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,GAG3B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;AAEnE,MAAM,CAAC,MAAM,gBAAgB,GAEzB,CAAC,EACH,KAAK,EACL,YAAY,GAAG,CAAC,EAChB,YAAY,GAAG,GAAG,EAClB,KAAK,GAAG,YAAY,EACpB,SAAS,GAAG,EAAE,EACd,cAAc,GAAG,SAAS,EAC1B,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,EAC5B,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,EACjC,YAAY,GAAG,CAAC,EAChB,SAAS,GAAG,IAAI,EAChB,iBAAiB,GAAG,0BAA0B,EAC9C,UAAU,GAAG,IAAI,EACjB,OAAO,GAAG,OAAO,EACjB,YAAY,GAAG,OAAO,EACtB,SAAS,EACT,cAAc,EACd,OAAO,EACP,YAAY,EACZ,UAAU,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,aAAa,GAAG,KAAK,EACrB,KAAK,EACL,MAAM,GACP,EAAE,EAAE;IACH,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpE,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE3D,MAAM,SAAS,GACb,SAAS,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C,CAAC;QACP,KAAK,CAAC,CAAC;QACP,GAAG;QACH,MAAM;QACN,MAAM;QACN,CAAC;QACD,YAAY;QACZ,CAAC;QACD,GAAG,CAAC,CAAC;QACL,GAAG,CAAC,CAAC;KACN,CAAC;IACF,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { CircularProgressProps, IndeterminateProgressProps, ValueProgressProps } from "../ProgressCommon";
|
|
3
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<ValueProgressProps & IndeterminateProgressProps & CircularProgressProps, "theme"> & {
|
|
4
|
+
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
5
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<ValueProgressProps & IndeterminateProgressProps & CircularProgressProps> & React.FC<ValueProgressProps & IndeterminateProgressProps & CircularProgressProps>, {}>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IndeterminateProgress from "../IndeterminateProgress";
|
|
3
|
+
import { CircularProgress as CircularProgressComponent } from "./CircularProgress";
|
|
4
|
+
import { withTheme } from "../../../theming";
|
|
5
|
+
const CircularProgress = (props) => {
|
|
6
|
+
if (props.indeterminate) {
|
|
7
|
+
return (React.createElement(IndeterminateProgress, { ProgressComponent: CircularProgressComponent, ...props }));
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return React.createElement(CircularProgressComponent, { ...props });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default withTheme(CircularProgress);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Progress/CircularProgress/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAM7D,OAAO,EAAE,gBAAgB,IAAI,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,gBAAgB,GAElB,CAAC,KAAK,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,aAAa,EAAE;QACvB,OAAO,CACL,oBAAC,qBAAqB,IACpB,iBAAiB,EACf,yBAAwE,KAEtE,KAAK,GACT,CACH,CAAC;KACH;SAAM;QACL,OAAO,oBAAC,yBAAyB,OAAK,KAAK,GAAI,CAAC;KACjD;AACH,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BaseProgressProps, ValueProgressProps } from "./ProgressCommon";
|
|
3
|
+
interface IndeterminateProgressProps extends BaseProgressProps {
|
|
4
|
+
ProgressComponent: React.FunctionComponent<ValueProgressProps>;
|
|
5
|
+
}
|
|
6
|
+
declare const IndeterminateProgress: React.FC<IndeterminateProgressProps>;
|
|
7
|
+
export default IndeterminateProgress;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { runOnJS, useAnimatedReaction, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
3
|
+
import { DEFAULT_ANIMATION_DURATION, } from "./ProgressCommon";
|
|
4
|
+
const IndeterminateProgress = ({ ProgressComponent, ...rest }) => {
|
|
5
|
+
const [pathWidth, setPathWidth] = React.useState(0);
|
|
6
|
+
const [value, setValue] = React.useState(0);
|
|
7
|
+
const [dashOffset, setDashOffset] = React.useState(0);
|
|
8
|
+
const animationDuration = rest.animationDuration || DEFAULT_ANIMATION_DURATION;
|
|
9
|
+
const currentOffset = useSharedValue(0);
|
|
10
|
+
// dashOffset animation done through state due to it not being a 'native' prop that reanimated can animate on the native thread
|
|
11
|
+
useAnimatedReaction(() => currentOffset.value, (result) => runOnJS(setDashOffset)(result));
|
|
12
|
+
const repeatIndeterminateAnimation = React.useCallback(() => {
|
|
13
|
+
if (value === 0) {
|
|
14
|
+
setValue(100);
|
|
15
|
+
currentOffset.value = withTiming(pathWidth, {
|
|
16
|
+
duration: animationDuration,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
setValue(0);
|
|
21
|
+
currentOffset.value = withTiming(0, {
|
|
22
|
+
duration: animationDuration,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}, [currentOffset, value, animationDuration, pathWidth]);
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
const timeout = setTimeout(() => {
|
|
28
|
+
repeatIndeterminateAnimation();
|
|
29
|
+
}, animationDuration);
|
|
30
|
+
return () => clearTimeout(timeout);
|
|
31
|
+
}, [animationDuration, repeatIndeterminateAnimation]);
|
|
32
|
+
return (React.createElement(ProgressComponent, { ...rest, testID: rest.testID || "indeterminate-progress", onFullPathWidth: (width) => {
|
|
33
|
+
var _a;
|
|
34
|
+
setPathWidth(width);
|
|
35
|
+
(_a = rest.onFullPathWidth) === null || _a === void 0 ? void 0 : _a.call(rest, width);
|
|
36
|
+
}, dashOffset: dashOffset, dashGap: pathWidth / 2, dashWidth: pathWidth / 2, animationDuration: animationDuration, value: 100 }));
|
|
37
|
+
};
|
|
38
|
+
export default IndeterminateProgress;
|
|
39
|
+
//# sourceMappingURL=IndeterminateProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndeterminateProgress.js","sourceRoot":"","sources":["../../../../src/components/Progress/IndeterminateProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,cAAc,EACd,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,0BAA0B,G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GAAG,EAAE;YAC9B,4BAA4B,EAAE,CAAC;QACjC,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACtB,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,EAAE,CAAC,iBAAiB,EAAE,4BAA4B,CAAC,CAAC,CAAC;IAEtD,OAAO,CACL,oBAAC,iBAAiB,OACZ,IAAI,EACR,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,wBAAwB,EAC/C,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;;YACzB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAA,IAAI,CAAC,eAAe,qDAAG,KAAK,CAAC,CAAC;QAChC,CAAC,EACD,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,SAAS,GAAG,CAAC,EACtB,SAAS,EAAE,SAAS,GAAG,CAAC,EACxB,iBAAiB,EAAE,iBAAiB,EACpC,KAAK,EAAE,GAAG,GACV,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LineProps } from "react-native-svg";
|
|
3
|
+
import Animated from "react-native-reanimated";
|
|
4
|
+
import { ValueProgressProps } from "../ProgressCommon";
|
|
5
|
+
export declare const AnimatedLine: React.ComponentClass<Animated.AnimateProps<LineProps>, any>;
|
|
6
|
+
export declare const LinearProgress: React.FC<ValueProgressProps>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Svg, { Line } from "react-native-svg";
|
|
3
|
+
import Animated, { useAnimatedProps, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
4
|
+
import { DEFAULT_ANIMATION_DURATION, } from "../ProgressCommon";
|
|
5
|
+
export const AnimatedLine = Animated.createAnimatedComponent(Line);
|
|
6
|
+
export const LinearProgress = ({ theme, minimumValue = 0, maximumValue = 100, value = minimumValue, thickness = 10, trackThickness = thickness, color = theme.colors.primary, trackColor = theme.colors.divider, trackOpacity = 1, showTrack = true, animationDuration = DEFAULT_ANIMATION_DURATION, isAnimated = true, lineCap = "round", trackLineCap = lineCap, dashWidth, trackDashWidth, dashGap, trackDashGap, dashOffset, trackDashOffset, customDashArray, trackCustomDashArray, onFullPathWidth, style, testID, }) => {
|
|
7
|
+
const [svgContainerWidth, setSvgContainerWidth] = React.useState(0);
|
|
8
|
+
const dashArray = dashWidth !== undefined
|
|
9
|
+
? `${dashWidth} ${dashGap || dashWidth}`
|
|
10
|
+
: undefined;
|
|
11
|
+
const trackDashArray = trackDashWidth !== undefined
|
|
12
|
+
? `${trackDashWidth} ${trackDashGap || trackDashWidth}`
|
|
13
|
+
: undefined;
|
|
14
|
+
const maxThickness = Math.max(thickness, trackThickness);
|
|
15
|
+
const thicknessOffset = maxThickness / 2; // This offset guarantees nothing is cut off by view bounds
|
|
16
|
+
const progressLineWidth = svgContainerWidth - thicknessOffset;
|
|
17
|
+
const trackProgressLineWidth = svgContainerWidth - thicknessOffset;
|
|
18
|
+
const currentFillPercentage = value / (maximumValue + minimumValue);
|
|
19
|
+
const currentProgressLineWidth = useSharedValue(currentFillPercentage * progressLineWidth);
|
|
20
|
+
const progressLineAnimatedProps = useAnimatedProps(() => {
|
|
21
|
+
const isBelowMinWidth = currentProgressLineWidth.value <= thicknessOffset;
|
|
22
|
+
return {
|
|
23
|
+
x2: Math.min(progressLineWidth, currentProgressLineWidth.value),
|
|
24
|
+
strokeOpacity: isBelowMinWidth ? 0.0 : 1.0,
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
currentProgressLineWidth.value = withTiming(progressLineWidth * currentFillPercentage, {
|
|
29
|
+
duration: isAnimated ? animationDuration : 0,
|
|
30
|
+
});
|
|
31
|
+
}, [
|
|
32
|
+
value,
|
|
33
|
+
progressLineWidth,
|
|
34
|
+
currentFillPercentage,
|
|
35
|
+
animationDuration,
|
|
36
|
+
currentProgressLineWidth,
|
|
37
|
+
maximumValue,
|
|
38
|
+
minimumValue,
|
|
39
|
+
isAnimated,
|
|
40
|
+
]);
|
|
41
|
+
return (React.createElement(Svg, { testID: testID !== null && testID !== void 0 ? testID : "linear-progress-component", onLayout: (event) => {
|
|
42
|
+
const width = event.nativeEvent.layout.width;
|
|
43
|
+
setSvgContainerWidth(width);
|
|
44
|
+
onFullPathWidth === null || onFullPathWidth === void 0 ? void 0 : onFullPathWidth(width);
|
|
45
|
+
}, style: [
|
|
46
|
+
{
|
|
47
|
+
height: maxThickness,
|
|
48
|
+
},
|
|
49
|
+
style,
|
|
50
|
+
] },
|
|
51
|
+
showTrack && (React.createElement(Line, { x1: thicknessOffset, y1: thicknessOffset, x2: trackProgressLineWidth, y2: thicknessOffset, stroke: trackColor, strokeWidth: trackThickness, strokeOpacity: trackOpacity, strokeLinecap: trackLineCap, strokeDasharray: trackCustomDashArray || trackDashArray, strokeDashoffset: trackDashOffset })),
|
|
52
|
+
React.createElement(AnimatedLine, { animatedProps: progressLineAnimatedProps, x1: thicknessOffset, y1: thicknessOffset, y2: thicknessOffset, stroke: color, strokeWidth: thickness, strokeLinecap: lineCap, strokeDasharray: customDashArray || dashArray, strokeDashoffset: dashOffset })));
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=LinearProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearProgress.js","sourceRoot":"","sources":["../../../../../src/components/Progress/LinearProgress/LinearProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,EAAE,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAC;AACxD,OAAO,QAAQ,EAAE,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,GAE3B,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ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IACH,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,sBAAsB,EAC1B,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,YAAY,EAC3B,aAAa,EAAE,YAAY,EAC3B,eAAe,EAAE,oBAAoB,IAAI,cAAc,EACvD,gBAAgB,EAAE,eAAe,GACjC,CACH;QACD,oBAAC,YAAY,IACX,aAAa,EAAE,yBAAyB,EACxC,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,eAAe,EACnB,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,KAAK,EACb,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,OAAO,EACtB,eAAe,EAAE,eAAe,IAAI,SAAS,EAC7C,gBAAgB,EAAE,UAAU,GAC5B,CACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { IndeterminateProgressProps, ValueProgressProps } from "../ProgressCommon";
|
|
3
|
+
declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<ValueProgressProps & IndeterminateProgressProps, "theme"> & {
|
|
4
|
+
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
5
|
+
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<ValueProgressProps & IndeterminateProgressProps> & React.FC<ValueProgressProps & IndeterminateProgressProps>, {}>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IndeterminateProgress from "../IndeterminateProgress";
|
|
3
|
+
import { LinearProgress as LinearProgressComponent } from "./LinearProgress";
|
|
4
|
+
import { withTheme } from "../../../theming";
|
|
5
|
+
const LinearProgress = (props) => {
|
|
6
|
+
if (props.indeterminate) {
|
|
7
|
+
return (React.createElement(IndeterminateProgress, { ProgressComponent: LinearProgressComponent, ...props }));
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return React.createElement(LinearProgressComponent, { ...props });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default withTheme(LinearProgress);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/Progress/LinearProgress/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAK7D,OAAO,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,cAAc,GAEhB,CAAC,KAAK,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,aAAa,EAAE;QACvB,OAAO,CACL,oBAAC,qBAAqB,IACpB,iBAAiB,EAAE,uBAAuB,KACtC,KAAK,GACT,CACH,CAAC;KACH;SAAM;QACL,OAAO,oBAAC,uBAAuB,OAAK,KAAK,GAAI,CAAC;KAC/C;AACH,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
3
|
+
declare type LineCap = "round" | "square";
|
|
4
|
+
export declare const DEFAULT_ANIMATION_DURATION = 500;
|
|
5
|
+
export interface BaseProgressProps {
|
|
6
|
+
thickness?: number;
|
|
7
|
+
trackThickness?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
trackColor?: string;
|
|
10
|
+
trackOpacity?: number;
|
|
11
|
+
showTrack?: boolean;
|
|
12
|
+
animationDuration?: number;
|
|
13
|
+
isAnimated?: boolean;
|
|
14
|
+
lineCap?: LineCap;
|
|
15
|
+
trackLineCap?: LineCap;
|
|
16
|
+
dashWidth?: string | number;
|
|
17
|
+
trackDashWidth?: string | number;
|
|
18
|
+
dashGap?: string | number;
|
|
19
|
+
trackDashGap?: string | number;
|
|
20
|
+
dashOffset?: string | number;
|
|
21
|
+
trackDashOffset?: string | number;
|
|
22
|
+
customDashArray?: string;
|
|
23
|
+
trackCustomDashArray?: string;
|
|
24
|
+
onFullPathWidth?: (width: number) => void;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
theme: Theme;
|
|
27
|
+
testID?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ValueProgressProps extends BaseProgressProps {
|
|
30
|
+
value?: number;
|
|
31
|
+
minimumValue?: number;
|
|
32
|
+
maximumValue?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface IndeterminateProgressProps extends BaseProgressProps {
|
|
35
|
+
indeterminate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface CircularProgressProps {
|
|
38
|
+
startPosition?: "left" | "top" | "right" | "bottom";
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressCommon.js","sourceRoot":"","sources":["../../../../src/components/Progress/ProgressCommon.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC"}
|
|
@@ -12,6 +12,7 @@ const SwipeableItem = ({ theme, style, children, Icon, closeOnPress, leftOpenVal
|
|
|
12
12
|
return Object.keys(object).length === 0;
|
|
13
13
|
};
|
|
14
14
|
const { onStartSwiping, onStopSwiping } = React.useContext(SwipeableListContext);
|
|
15
|
+
const swipeableRef = React.useRef(null);
|
|
15
16
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
16
17
|
const { borderStyles, marginStyles } = extractBorderAndMarginStyles(viewStyles);
|
|
17
18
|
const sizeStyles = extractSizeStyles(viewStyles);
|
|
@@ -49,7 +50,13 @@ const SwipeableItem = ({ theme, style, children, Icon, closeOnPress, leftOpenVal
|
|
|
49
50
|
throw Error("Colliding configuration in SwipeableItem. You cannot have SwipeableItemButton(s) on the swipe direction where swipe handling is configured. Either reset swipe configuration or remove the button(s).");
|
|
50
51
|
}
|
|
51
52
|
//Renders a single 'behind' item. Used for both buttons and swipe handler
|
|
52
|
-
const renderBehindItem = (item, index) => (React.createElement(Pressable, { key: index.toString(), onPress:
|
|
53
|
+
const renderBehindItem = (item, index) => (React.createElement(Pressable, { key: index.toString(), onPress: () => {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
(_a = item.onPress) === null || _a === void 0 ? void 0 : _a.call(item);
|
|
56
|
+
if ((_b = item.closeOnPress) !== null && _b !== void 0 ? _b : true) {
|
|
57
|
+
(_c = swipeableRef.current) === null || _c === void 0 ? void 0 : _c.closeRow();
|
|
58
|
+
}
|
|
59
|
+
}, style: [
|
|
53
60
|
styles.buttonContainer,
|
|
54
61
|
{ backgroundColor: item.backgroundColor || theme.colors.primary },
|
|
55
62
|
] },
|
|
@@ -60,7 +67,7 @@ const SwipeableItem = ({ theme, style, children, Icon, closeOnPress, leftOpenVal
|
|
|
60
67
|
return (React.createElement(View, { onLayout: (event) => {
|
|
61
68
|
setComponentWidth(event.nativeEvent.layout.width);
|
|
62
69
|
}, style: [styles.parentContainer, parentContainerStyles] },
|
|
63
|
-
React.createElement(SwipeRow, { leftOpenValue: isRightSwipeHandled ? 0 : leftOpenValue || defaultLeftOpenValue //If in swiping mode, don't keep open
|
|
70
|
+
React.createElement(SwipeRow, { ref: swipeableRef, leftOpenValue: isRightSwipeHandled ? 0 : leftOpenValue || defaultLeftOpenValue //If in swiping mode, don't keep open
|
|
64
71
|
, rightOpenValue: isLeftSwipeHandled ? 0 : rightOpenValue || defaultRightOpenValue, leftActivationValue: leftActivationValue || isRightSwipeHandled
|
|
65
72
|
? defaultLeftOpenValue * (swipeActivationPercentage / 100) //When swipe passes activation percentage then it should be considered activated (call onSwipe)
|
|
66
73
|
: defaultLeftOpenValue, rightActivationValue: rightActivationValue || isLeftSwipeHandled
|