react-native-boxes 1.4.42 → 1.4.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-boxes",
3
- "version": "1.4.42",
3
+ "version": "1.4.43",
4
4
  "description": "A react native library for rapid development of UI using boxes",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,29 @@
1
+ export const ViewType = {
2
+ BUTTON: 'button',
3
+ TEXT: 'text',
4
+ DIALOG: 'dialog',
5
+ DROPDOWN: 'dropdown',
6
+ WEBVIEW: 'webview',
7
+ BOX: 'box',
8
+ SWITCH: 'switch',
9
+ IMAGE: 'image',
10
+ TOOLBAR: 'toolbar',
11
+ BOTTOMBAR: 'bottombar'
12
+ }
13
+ export const TrackerUtils = {
14
+ textOf(value: any) {
15
+ if (typeof value == 'string') {
16
+ return value
17
+ }
18
+ if (typeof value == 'object') {
19
+ return 'object'
20
+ }
21
+ return "undefined"
22
+ }
23
+ }
24
+ export const UAType = {
25
+ CLICK: 'click',
26
+ VIEW: 'view',
27
+ NAVIGATE: 'navigate'
28
+ }
29
+ export type AnalyticTracker = (action: string, view: string, text?: string, extra?: any) => void
package/src/Bar.tsx CHANGED
@@ -8,6 +8,7 @@ import { Icon, getIcon } from "./Image";
8
8
  import { useSafeAreaInsets } from "react-native-safe-area-context";
9
9
  import { PressableView } from "./Button";
10
10
  import { isDesktop, isWeb } from "./utils";
11
+ import { UAType, ViewType } from "./Analytics";
11
12
 
12
13
  export interface Option {
13
14
  id: string,
@@ -88,6 +89,7 @@ export function SimpleToolbar(props: SimpleToolbarProps) {
88
89
  margin: 0,
89
90
  }}>
90
91
  <PressableView onPress={() => {
92
+ theme.onTrack(UAType.CLICK, ViewType.TOOLBAR, 'back')
91
93
  props.onHomePress && props.onHomePress()
92
94
  }}>
93
95
  {HomeIcon && <HomeIcon color={props.forgroundColor || theme.colors.invert.text} />}
@@ -109,6 +111,7 @@ export function SimpleToolbar(props: SimpleToolbarProps) {
109
111
  key={opt.id}
110
112
  accessibilityHint={title}
111
113
  onPress={() => {
114
+ theme.onTrack(UAType.CLICK, ViewType.TOOLBAR, 'option-' + opt.id)
112
115
  opt.onClick && opt.onClick(opt.id)
113
116
  }}>
114
117
  <ActionIcon
@@ -175,6 +178,7 @@ export function BottomNavBar(props: ViewProps &
175
178
  key={op.id}
176
179
  onPress={() => {
177
180
  op.onClick && op.onClick(op.id)
181
+ theme.onTrack(UAType.CLICK, ViewType.BOTTOMBAR, 'option-' + op.id)
178
182
  props.onSelect(op.id)
179
183
  }}>
180
184
  <Center >
package/src/Button.tsx CHANGED
@@ -4,6 +4,7 @@ import { ThemeContext } from "./ThemeContext";
4
4
  import { Center, HBox } from "./Box";
5
5
  import { TextView, TextViewProps } from "./Text";
6
6
  import { getIcon } from "./Image";
7
+ import { TrackerUtils, UAType, ViewType } from "./Analytics";
7
8
 
8
9
  export type ButtonViewProps = TextProps & TouchableHighlightProps & { icon?: any, text?: string, textStyle?: TextStyle, children?: any }
9
10
 
@@ -40,6 +41,10 @@ export function TransparentButton(props: TextProps & TouchableHighlightProps
40
41
  return (
41
42
  <TouchableHighlight
42
43
  {...props}
44
+ onPress={(e) => {
45
+ props.onPress && props.onPress(e)
46
+ theme.onTrack(UAType.CLICK, ViewType.BUTTON, (props.text || TrackerUtils.textOf(props.children)))
47
+ }}
43
48
  onPressIn={onPressIn}
44
49
  onPressOut={onPressOut}
45
50
  underlayColor={theme.colors.transparent}
@@ -108,6 +113,10 @@ export function ButtonView(props: ButtonViewProps) {
108
113
  return (
109
114
  <TouchableHighlight
110
115
  {...props}
116
+ onPress={(e) => {
117
+ props.onPress && props.onPress(e)
118
+ theme.onTrack(UAType.CLICK, ViewType.BUTTON, (props['aria-label'] ? props['aria-label'] + '-' : '') + (props.text || TrackerUtils.textOf(props.children)))
119
+ }}
111
120
  onPressIn={onPressIn}
112
121
  onPressOut={onPressOut}
113
122
  underlayColor={props.underlayColor || theme.colors.accentLight}
@@ -182,6 +191,10 @@ export function RightIconButton(props: ButtonViewProps) {
182
191
  return (
183
192
  <TouchableHighlight
184
193
  {...props}
194
+ onPress={(e) => {
195
+ props.onPress && props.onPress(e)
196
+ theme.onTrack(UAType.CLICK, ViewType.BUTTON, (props.text || TrackerUtils.textOf(props.children)))
197
+ }}
185
198
  onPressIn={onPressIn}
186
199
  onPressOut={onPressOut}
187
200
  underlayColor={props.underlayColor || theme.colors.accentLight}
@@ -301,22 +314,37 @@ export function LoadingButton(props: TextProps & TouchableHighlightProps
301
314
 
302
315
 
303
316
  export function PressableView(props: PressableProps) {
304
-
305
317
  //@ts-ignore
306
318
  return (<Pressable {...props} style={({ pressed }) => [{ opacity: pressed ? 0.7 : 1.0 }, props.style]} />)
307
319
  }
308
320
 
309
- export function SwitchView(props: SwitchProps) {
321
+ export function SwitchView(props: SwitchProps & { text: string, orientation: 'row' | 'column' }) {
310
322
  const theme = useContext(ThemeContext)
311
323
  return (
312
- <Switch
313
- trackColor={{
314
- false: theme.colors.caption,
315
- true: theme.colors.success
316
- }}
317
- thumbColor={props.value ? theme.colors.invert.text : theme.colors.text}
318
- ios_backgroundColor={theme.colors.caption}
319
- {...props}
320
- />
324
+ <HBox style={[{
325
+ flexDirection: props.orientation || 'row',
326
+ alignContent: 'center',
327
+ alignItems: 'center'
328
+ }, props.style]}>
329
+ <Switch
330
+ trackColor={{
331
+ false: theme.colors.caption,
332
+ true: theme.colors.success
333
+ }}
334
+ thumbColor={props.value ? theme.colors.invert.text : theme.colors.text}
335
+ ios_backgroundColor={theme.colors.caption}
336
+ onValueChange={(value) => {
337
+ props.onValueChange && props.onValueChange(value)
338
+ theme.onTrack(UAType.CLICK, ViewType.SWITCH, (props.text) + '-' + value, { value })
339
+ }}
340
+ {...props}
341
+ />
342
+ {
343
+ props.text && (
344
+ <TextView>{props.text}</TextView>
345
+ )
346
+ }
347
+ </HBox>
348
+
321
349
  )
322
350
  }
package/src/Modal.tsx CHANGED
@@ -11,6 +11,7 @@ import { CompositeTextInputView, CompositeTextInputViewProps } from './Input';
11
11
  import * as WebBrowser from 'expo-web-browser';
12
12
  import { TransparentCenterToolbar } from './Bar';
13
13
  import { GestureDetector, Gesture, Directions } from 'react-native-gesture-handler';
14
+ import { TrackerUtils, UAType, ViewType } from './Analytics';
14
15
 
15
16
 
16
17
  export type BottomSheetProps = {
@@ -37,6 +38,8 @@ export const BottomSheet = (props: BottomSheetProps) => {
37
38
 
38
39
  useEffect(() => {
39
40
  setModalVisible(props.visible)
41
+ if (props.visible)
42
+ theme.onTrack(UAType.VIEW, ViewType.DIALOG, (TrackerUtils.textOf(props.title)))
40
43
  }, [props.visible])
41
44
 
42
45
  function cancel() {
@@ -264,6 +267,7 @@ export function Expand(props: ViewProps & {
264
267
  const toggleExpand = () => {
265
268
  let newValue = !expanded
266
269
  setExpanded(newValue);
270
+ theme.onTrack(UAType.CLICK, ViewType.DIALOG, (newValue ? 'expand' : 'collaps') + '-' + props.title)
267
271
  };
268
272
  var onLayoutContent = (event: LayoutChangeEvent) => {
269
273
  if (!contentHeight) {
@@ -402,6 +406,11 @@ export const DropDownView = (props: DropDownViewProps) => {
402
406
  };
403
407
  const onSelect = (selectedId: string, opt: DropDownViewOption) => {
404
408
  props.onSelect(selectedId, opt)
409
+ theme.onTrack(UAType.CLICK, ViewType.DROPDOWN, 'select-' + props.title, {
410
+ value: selectedId,
411
+ title: opt.title,
412
+ displayType: displayType
413
+ })
405
414
  setVisible(false)
406
415
  }
407
416
  const shouldShowLabel = props.listType == 'horizontal-list' ? !visible : true
@@ -656,11 +665,12 @@ export function ConfirmationDialog(props: ConfirmationDialogProps) {
656
665
  padding: theme.dimens.space.lg,
657
666
  textAlign: 'center'
658
667
  }}>{props.message}</TextView>}
659
- <ButtonView text={confirmText as string} onPress={() => {
668
+ <ButtonView aria-label={props.title as string} text={confirmText as string} onPress={() => {
660
669
  props.onDismiss && props.onDismiss()
661
670
  props.onConfirm && props.onConfirm()
662
671
  }} />
663
672
  <TertiaryButtonView
673
+ aria-label={props.title as string}
664
674
  style={{
665
675
  marginTop: 0
666
676
  }}
@@ -703,6 +713,10 @@ export function WebBrowserView(props: {
703
713
  };
704
714
 
705
715
  useEffect(() => {
716
+ theme.onTrack(UAType.VIEW, ViewType.WEBVIEW, 'webview-' + props.title, {
717
+ url: props.url,
718
+ message: props.openMessage
719
+ })
706
720
  if (result == null)
707
721
  _handlePressButtonAsync()
708
722
  }, [])
@@ -3,6 +3,7 @@ import { Colors, Dimens, createStyle, DarkColors, LightColors, Fonts } from "./S
3
3
  import { randomColor } from "./utils"
4
4
  import { I18n, _i18n } from "./I18n"
5
5
  import { EdgeInsets } from "react-native-safe-area-context"
6
+ import { AnalyticTracker } from "./Analytics"
6
7
  const DEFAULT_STYLE = createStyle(Dimens, Colors, Fonts)
7
8
  export class Theme {
8
9
  appname: string = ''
@@ -11,6 +12,7 @@ export class Theme {
11
12
  colors: typeof Colors
12
13
  fonts: typeof Fonts
13
14
  i18n: I18n
15
+ onTrack: AnalyticTracker
14
16
  insets?: EdgeInsets
15
17
  randomColor = randomColor
16
18
  constructor(appname = '',
@@ -18,7 +20,8 @@ export class Theme {
18
20
  dimens = Dimens,
19
21
  fonts = Fonts,
20
22
  styles = DEFAULT_STYLE,
21
- i18n = _i18n) {
23
+ i18n = _i18n,
24
+ onTrack = () => { }) {
22
25
  this.appname = appname
23
26
  this.fonts = fonts ?? Fonts
24
27
  this.colors = colors ?? Colors
@@ -26,9 +29,14 @@ export class Theme {
26
29
  this.fonts = fonts ?? Fonts
27
30
  this.styles = styles ?? createStyle(this.dimens, this.colors, this.fonts)
28
31
  this.i18n = i18n
32
+ this.onTrack = onTrack
29
33
  }
30
34
  setInsets(insets: EdgeInsets) {
31
35
  this.insets = insets
32
36
  }
37
+
38
+ setTracking(onTrack: AnalyticTracker) {
39
+ this.onTrack = onTrack
40
+ }
33
41
  }
34
42
  export const ThemeContext = createContext(new Theme())