-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
138 lines (106 loc) · 3.27 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// main index.js
import { NativeModules, Platform } from "react-native";
const { Svprogresshud } = NativeModules;
if (Platform.OS == "android") Svprogresshud.init();
const between = (x, min, max) => {
return x >= min && x <= max;
};
const platformColor = ([R, G, B, a]) => {
let A = 255;
if (between(a, 0, 1)) {
A = Math.round(a * 255);
} else if (between(a, 0, 255)) {
A = Math.round(a);
}
if (Platform.OS == "android") {
return (
((A & 0xff) << 24) | ((R & 0xff) << 16) | ((G & 0xff) << 8) | (B & 0xff)
);
} else {
return (A << 24) + (R << 16) + (G << 8) + B;
}
};
class SVProgressHUD {
static show(status) {
Svprogresshud.show(status);
}
static showProgress(progress = 0.0, status) {
Svprogresshud.showProgress(progress, status);
}
static dismiss(delay = 0.0) {
Svprogresshud.dismiss(delay);
}
static showInfo(status) {
Svprogresshud.showInfo(status);
}
static showSuccess(status) {
Svprogresshud.showSuccess(status);
}
static showError(status) {
Svprogresshud.showError(status);
}
static setDefaultStyle(style = "light") {
Svprogresshud.setDefaultStyle(style);
}
static setDefaultMaskType(maskType = "none") {
Svprogresshud.setDefaultMaskType(maskType);
}
static setDefaultAnimationType(type = "flat") {
Svprogresshud.setDefaultAnimationType(type);
}
static setMinimumSize(width = 0.0, height = 0.0) {
Svprogresshud.setMinimumSize(width, height);
}
static setRingThickness(ringThickness = 2.0) {
Svprogresshud.setRingThickness(ringThickness);
}
static setRingRadius(radius = 18.0) {
Svprogresshud.setRingRadius(radius);
}
static setRingNoTextRadius(radius = 24.0) {
Svprogresshud.setRingNoTextRadius(radius);
}
static setCornerRadius(cornerRadius = 14.0) {
Svprogresshud.setCornerRadius(cornerRadius);
}
static setBorderColor(color) {
Svprogresshud.setBorderColor(platformColor(color));
}
static setBorderWidth(width = 0.0) {
Svprogresshud.setBorderWidth(width);
}
static setForegroundColor(color) {
Svprogresshud.setForegroundColor(platformColor(color));
}
static setForegroundImageColor(color) {
Svprogresshud.setForegroundImageColor(platformColor(color));
}
static setBackgroundColor(color) {
Svprogresshud.setBackgroundColor(platformColor(color));
}
static setBackgroundLayerColor(color) {
Svprogresshud.setBackgroundLayerColor(platformColor(color));
}
static setImageViewSize(width = 28.0, height = 28.0) {
Svprogresshud.setImageViewSize(width, height);
}
static setShouldTintImages(shouldTintImages = true) {
Svprogresshud.setShouldTintImages(shouldTintImages);
}
static setMinimumDismissTimeInterval(interval = 5000.0) {
Svprogresshud.setMinimumDismissTimeInterval(interval);
}
static setMaximumDismissTimeInterval(interval = 15000.0) {
Svprogresshud.setMaximumDismissTimeInterval(interval);
}
static setFadeInAnimationDuration(duration = 150.0) {
Svprogresshud.setFadeInAnimationDuration(duration);
}
static setFadeOutAnimationDuration(duration = 150.0) {
Svprogresshud.setFadeOutAnimationDuration(duration);
}
static setHapticsEnabled(hapticsEnabled = false) {
Svprogresshud.setHapticsEnabled(hapticsEnabled);
}
}
export default SVProgressHUD;