expo-snowui 1.0.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.
- package/LICENSE.txt +674 -0
- package/README.md +16 -0
- package/lib/module/component/snow-break.js +15 -0
- package/lib/module/component/snow-break.js.map +1 -0
- package/lib/module/component/snow-dropdown.js +66 -0
- package/lib/module/component/snow-dropdown.js.map +1 -0
- package/lib/module/component/snow-fill-view.js +40 -0
- package/lib/module/component/snow-fill-view.js.map +1 -0
- package/lib/module/component/snow-grid.js +70 -0
- package/lib/module/component/snow-grid.js.map +1 -0
- package/lib/module/component/snow-header.js +20 -0
- package/lib/module/component/snow-header.js.map +1 -0
- package/lib/module/component/snow-image-button.js +98 -0
- package/lib/module/component/snow-image-button.js.map +1 -0
- package/lib/module/component/snow-image-grid.js +84 -0
- package/lib/module/component/snow-image-grid.js.map +1 -0
- package/lib/module/component/snow-input.js +51 -0
- package/lib/module/component/snow-input.js.map +1 -0
- package/lib/module/component/snow-label.js +20 -0
- package/lib/module/component/snow-label.js.map +1 -0
- package/lib/module/component/snow-modal.js +49 -0
- package/lib/module/component/snow-modal.js.map +1 -0
- package/lib/module/component/snow-range-slider.js +247 -0
- package/lib/module/component/snow-range-slider.js.map +1 -0
- package/lib/module/component/snow-safe-area.js +22 -0
- package/lib/module/component/snow-safe-area.js.map +1 -0
- package/lib/module/component/snow-tabs.js +62 -0
- package/lib/module/component/snow-tabs.js.map +1 -0
- package/lib/module/component/snow-text-button.js +102 -0
- package/lib/module/component/snow-text-button.js.map +1 -0
- package/lib/module/component/snow-text.js +34 -0
- package/lib/module/component/snow-text.js.map +1 -0
- package/lib/module/component/snow-toggle.js +38 -0
- package/lib/module/component/snow-toggle.js.map +1 -0
- package/lib/module/context/snow-focus-context.js +39 -0
- package/lib/module/context/snow-focus-context.js.map +1 -0
- package/lib/module/context/snow-style-context.js +54 -0
- package/lib/module/context/snow-style-context.js.map +1 -0
- package/lib/module/index.js +63 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/snow-app.js +40 -0
- package/lib/module/snow-app.js.map +1 -0
- package/lib/module/snow-style.js +392 -0
- package/lib/module/snow-style.js.map +1 -0
- package/lib/module/snow-ui.js +19 -0
- package/lib/module/snow-ui.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/index.d.ts +42 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +163 -0
- package/src/component/snow-break.js +9 -0
- package/src/component/snow-dropdown.js +64 -0
- package/src/component/snow-fill-view.js +36 -0
- package/src/component/snow-grid.js +74 -0
- package/src/component/snow-header.js +18 -0
- package/src/component/snow-image-button.js +98 -0
- package/src/component/snow-image-grid.js +87 -0
- package/src/component/snow-input.js +47 -0
- package/src/component/snow-label.js +18 -0
- package/src/component/snow-modal.js +46 -0
- package/src/component/snow-range-slider.js +263 -0
- package/src/component/snow-safe-area.js +17 -0
- package/src/component/snow-tabs.js +62 -0
- package/src/component/snow-text-button.js +106 -0
- package/src/component/snow-text.js +31 -0
- package/src/component/snow-toggle.js +32 -0
- package/src/context/snow-focus-context.js +37 -0
- package/src/context/snow-style-context.js +46 -0
- package/src/index.tsx +63 -0
- package/src/snow-app.js +27 -0
- package/src/snow-style.js +399 -0
- package/src/snow-ui.js +16 -0
package/package.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "expo-snowui",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "GUI components and contexts shared by the snowsuite apps",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-snowui-example",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"typecheck": "tsc",
|
|
38
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
+
"clean": "del-cli lib",
|
|
40
|
+
"prepare": "bob build",
|
|
41
|
+
"release": "release-it --only-version"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"react-native",
|
|
45
|
+
"ios",
|
|
46
|
+
"android"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/XBigTK13X/react-native-snowui.git"
|
|
51
|
+
},
|
|
52
|
+
"author": "XBigTK13X <xbigtk13x@gmail.com> (https://github.com/XBigTK13X)",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/XBigTK13X/react-native-snowui/issues"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/XBigTK13X/react-native-snowui#readme",
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"registry": "https://registry.npmjs.org/"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@babel/core": "^7.28.4",
|
|
63
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
64
|
+
"@eslint/compat": "^1.3.2",
|
|
65
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
66
|
+
"@eslint/js": "^9.35.0",
|
|
67
|
+
"@evilmartians/lefthook": "^1.12.3",
|
|
68
|
+
"@react-native-tvos/config-tv": "0.1.4",
|
|
69
|
+
"@react-native/babel-preset": "0.81.1",
|
|
70
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
71
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/react": "^19.1.12",
|
|
74
|
+
"babel-preset-expo": "^54.0.2",
|
|
75
|
+
"commitlint": "^19.8.1",
|
|
76
|
+
"del-cli": "^6.0.0",
|
|
77
|
+
"eslint": "^9.35.0",
|
|
78
|
+
"eslint-config-prettier": "^10.1.8",
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"prettier": "^3.6.2",
|
|
82
|
+
"react": "19.1.0",
|
|
83
|
+
"react-native": "npm:react-native-tvos@0.81.4-0",
|
|
84
|
+
"react-native-builder-bob": "^0.40.13",
|
|
85
|
+
"release-it": "^19.0.4",
|
|
86
|
+
"typescript": "^5.9.2"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"react": "*",
|
|
90
|
+
"react-native": "*"
|
|
91
|
+
},
|
|
92
|
+
"workspaces": [
|
|
93
|
+
"example"
|
|
94
|
+
],
|
|
95
|
+
"packageManager": "yarn@3.6.1",
|
|
96
|
+
"jest": {
|
|
97
|
+
"preset": "react-native",
|
|
98
|
+
"modulePathIgnorePatterns": [
|
|
99
|
+
"<rootDir>/example/node_modules",
|
|
100
|
+
"<rootDir>/lib/"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"commitlint": {
|
|
104
|
+
"extends": [
|
|
105
|
+
"@commitlint/config-conventional"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"release-it": {
|
|
109
|
+
"git": {
|
|
110
|
+
"commitMessage": "chore: release ${version}",
|
|
111
|
+
"tagName": "v${version}"
|
|
112
|
+
},
|
|
113
|
+
"npm": {
|
|
114
|
+
"publish": true
|
|
115
|
+
},
|
|
116
|
+
"github": {
|
|
117
|
+
"release": true
|
|
118
|
+
},
|
|
119
|
+
"plugins": {
|
|
120
|
+
"@release-it/conventional-changelog": {
|
|
121
|
+
"preset": {
|
|
122
|
+
"name": "angular"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"prettier": {
|
|
128
|
+
"quoteProps": "consistent",
|
|
129
|
+
"singleQuote": true,
|
|
130
|
+
"tabWidth": 2,
|
|
131
|
+
"trailingComma": "es5",
|
|
132
|
+
"useTabs": false
|
|
133
|
+
},
|
|
134
|
+
"react-native-builder-bob": {
|
|
135
|
+
"source": "src",
|
|
136
|
+
"output": "lib",
|
|
137
|
+
"targets": [
|
|
138
|
+
[
|
|
139
|
+
"module",
|
|
140
|
+
{
|
|
141
|
+
"esm": true
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
"typescript",
|
|
146
|
+
{
|
|
147
|
+
"project": "tsconfig.build.json"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"create-react-native-library": {
|
|
153
|
+
"languages": "js",
|
|
154
|
+
"type": "library",
|
|
155
|
+
"version": "0.54.3"
|
|
156
|
+
},
|
|
157
|
+
"dependencies": {
|
|
158
|
+
"expo": "^54.0.9",
|
|
159
|
+
"expo-image": "^3.0.8",
|
|
160
|
+
"lodash": "^4.17.21",
|
|
161
|
+
"use-debounce": "^10.0.6"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { View } from 'react-native'
|
|
2
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
3
|
+
|
|
4
|
+
export function SnowBreak(props) {
|
|
5
|
+
const { SnowStyle } = useStyleContext(props)
|
|
6
|
+
return <View style={SnowStyle.component.break} />
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default SnowBreak
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { View } from 'react-native'
|
|
2
|
+
import SnowGrid from './snow-grid'
|
|
3
|
+
import SnowTextButton from './snow-text-button'
|
|
4
|
+
import SnowLabel from './snow-label'
|
|
5
|
+
|
|
6
|
+
/* spread props
|
|
7
|
+
nextFocusLeft
|
|
8
|
+
nextFocusRight
|
|
9
|
+
nextFocusUp
|
|
10
|
+
nextFocusDown
|
|
11
|
+
snowStyle
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export function SnowDropdown(props) {
|
|
15
|
+
if (!props.options) {
|
|
16
|
+
return null
|
|
17
|
+
}
|
|
18
|
+
if (props.valueIndex === undefined || props.valueIndex === null) {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const choose = (chosenIndex) => {
|
|
23
|
+
if (props.onValueChange) {
|
|
24
|
+
props.onValueChange(chosenIndex)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const renderItem = (item, itemIndex) => {
|
|
29
|
+
let selected = false
|
|
30
|
+
if (!props.skipDefaultFocus) {
|
|
31
|
+
if (itemIndex === props.valueIndex) {
|
|
32
|
+
selected = true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return <SnowTextButton
|
|
36
|
+
{...props}
|
|
37
|
+
fade={selected && props.fade}
|
|
38
|
+
selected={selected}
|
|
39
|
+
title={item.name ? item.name : item}
|
|
40
|
+
onPress={() => { choose(item.index ? item.index : itemIndex) }} />
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (props.title) {
|
|
44
|
+
return <View>
|
|
45
|
+
<SnowLabel center>{props.title}</SnowLabel>
|
|
46
|
+
<SnowGrid
|
|
47
|
+
shouldFocus={props.shouldFocus}
|
|
48
|
+
itemsPerRow={props.itemsPerRow}
|
|
49
|
+
items={props.options}
|
|
50
|
+
renderItem={renderItem}
|
|
51
|
+
/>
|
|
52
|
+
</View>
|
|
53
|
+
}
|
|
54
|
+
return (
|
|
55
|
+
<SnowGrid
|
|
56
|
+
shouldFocus={props.shouldFocus}
|
|
57
|
+
itemsPerRow={props.itemsPerRow}
|
|
58
|
+
items={props.options}
|
|
59
|
+
renderItem={renderItem}
|
|
60
|
+
/>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default SnowDropdown
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ScrollView, View } from 'react-native'
|
|
2
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
3
|
+
|
|
4
|
+
export function SnowFillView(props) {
|
|
5
|
+
// FlatList often overflows outside of the viewport without enabling scrolling.
|
|
6
|
+
// This commonly happens when any parent container is not set to flex: 1
|
|
7
|
+
const { SnowStyle } = useStyleContext(props)
|
|
8
|
+
if (props.scroll) {
|
|
9
|
+
let viewStyle = [SnowStyle.component.fillView.default]
|
|
10
|
+
let scrollStyle = []
|
|
11
|
+
if (props.flexStart) {
|
|
12
|
+
scrollStyle = [SnowStyle.component.fillView.flexStart]
|
|
13
|
+
}
|
|
14
|
+
if (props.style) {
|
|
15
|
+
viewStyle.push(props.style)
|
|
16
|
+
}
|
|
17
|
+
return <ScrollView
|
|
18
|
+
style={viewStyle}
|
|
19
|
+
contentContainerStyle={scrollStyle}
|
|
20
|
+
children={props.children}
|
|
21
|
+
/>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let style = [SnowStyle.component.fillView.default]
|
|
25
|
+
if (props.flexStart) {
|
|
26
|
+
style.push(SnowStyle.component.fillView.flexStart)
|
|
27
|
+
}
|
|
28
|
+
if (props.style) {
|
|
29
|
+
style.push(props.style)
|
|
30
|
+
}
|
|
31
|
+
return (
|
|
32
|
+
<View style={style} children={props.children} />
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default SnowFillView
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
FlatList
|
|
5
|
+
} from 'react-native'
|
|
6
|
+
|
|
7
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
8
|
+
|
|
9
|
+
export function SnowGrid(props) {
|
|
10
|
+
if (!props.items && !props.children) {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
let items = props.items
|
|
14
|
+
if (!props.items) {
|
|
15
|
+
// Without this, if a ternary `{x?x:null}` nullable component will leave a gap in the grid
|
|
16
|
+
items = React.Children.toArray(props.children)
|
|
17
|
+
}
|
|
18
|
+
items = items.filter(child => child !== null)
|
|
19
|
+
if (!items || !items.length) {
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { SnowStyle } = useStyleContext(props)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
let itemsPerRow = 5
|
|
27
|
+
if (props.itemsPerRow) {
|
|
28
|
+
itemsPerRow = props.itemsPerRow
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let itemStyle = [
|
|
32
|
+
{ flexBasis: `${100 / itemsPerRow}%` }
|
|
33
|
+
]
|
|
34
|
+
let gridStyle = []
|
|
35
|
+
if (props.gridStyle) {
|
|
36
|
+
gridStyle.push(props.gridStyle)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (props.short) {
|
|
40
|
+
gridStyle.push(SnowStyle.component.grid.short)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let renderItem = (item, itemIndex) => {
|
|
44
|
+
return item
|
|
45
|
+
}
|
|
46
|
+
if (props.renderItem) {
|
|
47
|
+
renderItem = props.renderItem
|
|
48
|
+
}
|
|
49
|
+
let columnStyle = null
|
|
50
|
+
if (itemsPerRow > 1) {
|
|
51
|
+
// If you try to style the column when 1 item per row, flat list throws an error
|
|
52
|
+
columnStyle = SnowStyle.component.grid.list
|
|
53
|
+
}
|
|
54
|
+
return (
|
|
55
|
+
<View style={gridStyle}>
|
|
56
|
+
<FlatList
|
|
57
|
+
scrollEnabled={props.scroll === true}
|
|
58
|
+
numColumns={itemsPerRow}
|
|
59
|
+
contentContainerStyle={SnowStyle.component.grid.list}
|
|
60
|
+
columnWrapperStyle={columnStyle}
|
|
61
|
+
data={items}
|
|
62
|
+
renderItem={({ item, index, separators }) => {
|
|
63
|
+
return (
|
|
64
|
+
<View style={itemStyle}>
|
|
65
|
+
{renderItem(item, index)}
|
|
66
|
+
</View>
|
|
67
|
+
)
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
</View >
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default SnowGrid
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Text, View } from 'react-native'
|
|
2
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
3
|
+
import SnowText from './snow-text'
|
|
4
|
+
|
|
5
|
+
export function SnowHeader(props) {
|
|
6
|
+
const { SnowStyle } = useStyleContext(props)
|
|
7
|
+
return (
|
|
8
|
+
<SnowText
|
|
9
|
+
skipDefault
|
|
10
|
+
center={props.center}
|
|
11
|
+
noSelect={props.noSelect}
|
|
12
|
+
style={SnowStyle.component.header}
|
|
13
|
+
children={props.children}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default SnowHeader
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { TouchableOpacity, View, Platform } from 'react-native';
|
|
3
|
+
import SnowText from './snow-text'
|
|
4
|
+
import { Image } from 'expo-image'
|
|
5
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
6
|
+
|
|
7
|
+
/* spread props
|
|
8
|
+
nextFocusLeft
|
|
9
|
+
nextFocusRight
|
|
10
|
+
nextFocusUp
|
|
11
|
+
nextFocusDown
|
|
12
|
+
onPress
|
|
13
|
+
onLongPress
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export function SnowImageButton(props) {
|
|
17
|
+
const { SnowStyle } = useStyleContext(props)
|
|
18
|
+
|
|
19
|
+
const [focused, setFocused] = React.useState(false)
|
|
20
|
+
const touchRef = React.useRef(null)
|
|
21
|
+
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (props.shouldFocus) {
|
|
24
|
+
touchRef.current.focus()
|
|
25
|
+
}
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
let fontStyle = [SnowStyle.component.imageButton.text]
|
|
29
|
+
let title = props.title
|
|
30
|
+
if (title && title.length > 20) {
|
|
31
|
+
fontStyle.push(SnowStyle.component.imageButton.smallText)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (title && title.length > 40) {
|
|
35
|
+
title = title.substring(0, 40) + '...'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const wrapperStyle = [SnowStyle.component.imageButton.wrapper]
|
|
39
|
+
const imageStyle = [SnowStyle.component.imageButton.image]
|
|
40
|
+
if (props.wide) {
|
|
41
|
+
wrapperStyle.push(SnowStyle.component.imageButton.wrapperWide)
|
|
42
|
+
imageStyle.push(SnowStyle.component.imageButton.imageWide)
|
|
43
|
+
}
|
|
44
|
+
if (props.square) {
|
|
45
|
+
wrapperStyle.push(SnowStyle.component.imageButton.wrapperSquare)
|
|
46
|
+
imageStyle.push(SnowStyle.component.imageButton.imageSquare)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let textWrapperStyle = [SnowStyle.component.imageButton.textWrapper]
|
|
50
|
+
|
|
51
|
+
if (props.dull) {
|
|
52
|
+
textWrapperStyle.push(SnowStyle.component.imageButton.dull)
|
|
53
|
+
}
|
|
54
|
+
if (props.selected) {
|
|
55
|
+
wrapperStyle.push(SnowStyle.component.imageButton.selected)
|
|
56
|
+
textWrapperStyle.push(SnowStyle.component.imageButton.selected)
|
|
57
|
+
}
|
|
58
|
+
if (focused && Platform.isTV) {
|
|
59
|
+
wrapperStyle.push(SnowStyle.component.imageButton.focused)
|
|
60
|
+
textWrapperStyle.push(SnowStyle.component.imageButton.focused)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let imageSource = null
|
|
64
|
+
if (props.imageUrl) {
|
|
65
|
+
imageSource = { uri: props.imageUrl }
|
|
66
|
+
}
|
|
67
|
+
if (props.imageSource) {
|
|
68
|
+
imageSource = props.imageSource
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<View>
|
|
73
|
+
<TouchableOpacity
|
|
74
|
+
{...props}
|
|
75
|
+
ref={touchRef}
|
|
76
|
+
activeOpacity={1.0}
|
|
77
|
+
onFocus={() => { setFocused(true) }}
|
|
78
|
+
onBlur={() => { setFocused(false) }}
|
|
79
|
+
style={wrapperStyle}
|
|
80
|
+
focusable={true}
|
|
81
|
+
hasTVPreferredFocus={props.shouldFocus}
|
|
82
|
+
>
|
|
83
|
+
<Image
|
|
84
|
+
style={imageStyle}
|
|
85
|
+
contentFit="contain"
|
|
86
|
+
source={imageSource}
|
|
87
|
+
placeholder={props.placeholder}
|
|
88
|
+
/>
|
|
89
|
+
<View style={textWrapperStyle}>
|
|
90
|
+
<SnowText style={fontStyle}>{title}</SnowText>
|
|
91
|
+
</View>
|
|
92
|
+
|
|
93
|
+
</TouchableOpacity>
|
|
94
|
+
</View>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default SnowImageButton
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { View } from 'react-native'
|
|
3
|
+
import SnowGrid from './snow-grid'
|
|
4
|
+
import SnowImageButton from './snow-image-button'
|
|
5
|
+
import SnowLabel from './snow-label'
|
|
6
|
+
|
|
7
|
+
/* spread props
|
|
8
|
+
snowStyle
|
|
9
|
+
nextFocusLeft
|
|
10
|
+
nextFocusRight
|
|
11
|
+
nextFocusUp
|
|
12
|
+
nextFocusDown
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export function SnowImageGrid(props) {
|
|
16
|
+
if (!props.items || !props.items.length) {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
const [toggledItems, setToggledItems] = React.useState({})
|
|
20
|
+
const itemsPerRow = props.itemsPerRow || 5
|
|
21
|
+
const renderItem = (item, itemIndex) => {
|
|
22
|
+
let imageUrl = null
|
|
23
|
+
if (props.getItemImageUrl) {
|
|
24
|
+
imageUrl = props.getItemImageUrl(item)
|
|
25
|
+
}
|
|
26
|
+
let imageSource = null
|
|
27
|
+
if (props.getItemImageSource) {
|
|
28
|
+
imageSource = props.getItemImageSource(item)
|
|
29
|
+
}
|
|
30
|
+
const itemName = props.getItemName(item)
|
|
31
|
+
|
|
32
|
+
let toggled = toggledItems.hasOwnProperty(item.id)
|
|
33
|
+
|
|
34
|
+
let isDull = false
|
|
35
|
+
if (!props.disableToggle) {
|
|
36
|
+
if (props.getItemToggleStatus && props.getItemToggleStatus(item)) {
|
|
37
|
+
isDull = true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return <SnowImageButton
|
|
42
|
+
{...props}
|
|
43
|
+
wide={props.wideImage}
|
|
44
|
+
dull={isDull}
|
|
45
|
+
imageUrl={imageUrl}
|
|
46
|
+
imageSource={imageSource}
|
|
47
|
+
onPress={() => { if (props.onPress) { props.onPress(item) } }}
|
|
48
|
+
onLongPress={() => {
|
|
49
|
+
if (props.onLongPress) {
|
|
50
|
+
props.onLongPress(item)
|
|
51
|
+
}
|
|
52
|
+
if (props.longPressToggle) {
|
|
53
|
+
setToggledItems((prev) => {
|
|
54
|
+
let result = { ...prev }
|
|
55
|
+
if (toggled) {
|
|
56
|
+
delete result[item.id]
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
result[item.id] = true
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return result
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
title={itemName}
|
|
67
|
+
/>
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<View>
|
|
72
|
+
{props.title ?
|
|
73
|
+
<SnowLabel>
|
|
74
|
+
{props.title} ({props.items.length})
|
|
75
|
+
</SnowLabel>
|
|
76
|
+
: null}
|
|
77
|
+
<SnowGrid
|
|
78
|
+
shouldFocus={props.shouldFocus}
|
|
79
|
+
items={props.items}
|
|
80
|
+
renderItem={renderItem}
|
|
81
|
+
itemsPerRow={itemsPerRow}
|
|
82
|
+
/>
|
|
83
|
+
</View>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default SnowImageGrid
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { TextInput } from 'react-native'
|
|
3
|
+
import { useDebouncedCallback } from 'use-debounce'
|
|
4
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
5
|
+
|
|
6
|
+
/* spreadble props
|
|
7
|
+
secureTextEntry
|
|
8
|
+
nextFocusLeft
|
|
9
|
+
nextFocusRight
|
|
10
|
+
nextFocusUp
|
|
11
|
+
nextFocusDown
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export function SnowInput(props) {
|
|
15
|
+
const { SnowStyle, SnowConfig } = useStyleContext(props)
|
|
16
|
+
let textStyle = [SnowStyle.component.input.text]
|
|
17
|
+
if (props.short) {
|
|
18
|
+
textStyle.push(SnowStyle.component.input.small)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let onDebounce = null
|
|
22
|
+
if (props.onDebounce) {
|
|
23
|
+
onDebounce = useDebouncedCallback(props.onDebounce, SnowConfig.inputDebounceMilliseconds)
|
|
24
|
+
}
|
|
25
|
+
return <TextInput
|
|
26
|
+
{...props}
|
|
27
|
+
style={textStyle}
|
|
28
|
+
focusable={true}
|
|
29
|
+
editable={true}
|
|
30
|
+
onChangeText={(val) => {
|
|
31
|
+
if (props.onValueChange) {
|
|
32
|
+
props.onValueChange(val)
|
|
33
|
+
}
|
|
34
|
+
if (onDebounce) {
|
|
35
|
+
onDebounce(val)
|
|
36
|
+
}
|
|
37
|
+
}}
|
|
38
|
+
onSubmitEditing={() => {
|
|
39
|
+
if (props.onSubmit) {
|
|
40
|
+
props.onSubmit()
|
|
41
|
+
}
|
|
42
|
+
}}
|
|
43
|
+
value={props.value}
|
|
44
|
+
/>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default SnowInput
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { View, Text } from 'react-native'
|
|
2
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
3
|
+
import SnowText from './snow-text'
|
|
4
|
+
|
|
5
|
+
export function SnowLabel(props) {
|
|
6
|
+
const { SnowStyle } = useStyleContext(props)
|
|
7
|
+
return (
|
|
8
|
+
<SnowText
|
|
9
|
+
skipDefault
|
|
10
|
+
center={props.center}
|
|
11
|
+
noSelect={props.noSelect}
|
|
12
|
+
style={SnowStyle.component.label}
|
|
13
|
+
children={props.children}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default SnowLabel
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Modal } from 'react-native'
|
|
2
|
+
import SnowFillView from './snow-fill-view'
|
|
3
|
+
import { useStyleContext } from '../context/snow-style-context'
|
|
4
|
+
|
|
5
|
+
export function SnowModal(props) {
|
|
6
|
+
const { SnowStyle } = useStyleContext(props)
|
|
7
|
+
|
|
8
|
+
let style = [SnowStyle.component.modal.prompt]
|
|
9
|
+
if (props.transparent) {
|
|
10
|
+
style.push(SnowStyle.component.modal.transparent)
|
|
11
|
+
}
|
|
12
|
+
if (props.center) {
|
|
13
|
+
style.push(SnowStyle.component.modal.center)
|
|
14
|
+
}
|
|
15
|
+
if (props.contentStyle) {
|
|
16
|
+
style.push(props.contentStyle)
|
|
17
|
+
}
|
|
18
|
+
if (props.wrapper === false) {
|
|
19
|
+
return (
|
|
20
|
+
<Modal
|
|
21
|
+
navigationBarTranslucent
|
|
22
|
+
statusBarTranslucent
|
|
23
|
+
transparent={props.transparent}
|
|
24
|
+
style={style}
|
|
25
|
+
onRequestClose={props.onRequestClose}
|
|
26
|
+
children={props.children} />
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
let modalStyle = [SnowStyle.component.modal.prompt]
|
|
30
|
+
if (props.modalStyle) {
|
|
31
|
+
modalStyle.push(modalStyle)
|
|
32
|
+
}
|
|
33
|
+
return <Modal
|
|
34
|
+
style={modalStyle}
|
|
35
|
+
navigationBarTranslucent
|
|
36
|
+
statusBarTranslucent
|
|
37
|
+
transparent={props.transparent}
|
|
38
|
+
onRequestClose={props.onRequestClose}>
|
|
39
|
+
<SnowFillView
|
|
40
|
+
scroll={props.scroll}
|
|
41
|
+
children={props.children}
|
|
42
|
+
style={style} />
|
|
43
|
+
</Modal>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default SnowModal
|