@planningcenter/chat-react-native 4.3.0-rc.7 → 4.3.0-rc.8

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,7 @@
1
+ interface SearchFieldProps {
2
+ term: string;
3
+ onChange: (term: string) => void;
4
+ }
5
+ export declare function SearchField({ term, onChange }: SearchFieldProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=search_field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_field.d.ts","sourceRoot":"","sources":["../../../../src/screens/search/components/search_field.tsx"],"names":[],"mappings":"AAQA,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACjC;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAwC/D"}
@@ -0,0 +1,152 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { useRef } from 'react';
3
+ import { Pressable, StyleSheet, View } from 'react-native';
4
+ import { Icon } from '../../../components';
5
+ import { AutoFocusAwareTextInput } from '../../../components/display/text_input';
6
+ import { useTheme } from '../../../hooks';
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ const PLACEHOLDER = 'Search titles and messages';
9
+ export function SearchField(t0) {
10
+ const $ = _c(21);
11
+ const {
12
+ term,
13
+ onChange
14
+ } = t0;
15
+ const styles = useStyles();
16
+ const {
17
+ colors
18
+ } = useTheme();
19
+ const inputRef = useRef(null);
20
+ let t1;
21
+ if ($[0] !== onChange) {
22
+ t1 = () => {
23
+ onChange("");
24
+ inputRef.current?.clear();
25
+ inputRef.current?.focus();
26
+ };
27
+ $[0] = onChange;
28
+ $[1] = t1;
29
+ } else {
30
+ t1 = $[1];
31
+ }
32
+ const clear = t1;
33
+ let t2;
34
+ if ($[2] !== colors.iconColorDefaultSecondary) {
35
+ t2 = /*#__PURE__*/_jsx(Icon, {
36
+ name: "general.search",
37
+ size: 16,
38
+ color: colors.iconColorDefaultSecondary
39
+ });
40
+ $[2] = colors.iconColorDefaultSecondary;
41
+ $[3] = t2;
42
+ } else {
43
+ t2 = $[3];
44
+ }
45
+ let t3;
46
+ if ($[4] !== colors.textColorDefaultPlaceholder || $[5] !== onChange || $[6] !== styles.input || $[7] !== term) {
47
+ t3 = /*#__PURE__*/_jsx(AutoFocusAwareTextInput, {
48
+ autoFocus: true,
49
+ autoCorrect: false,
50
+ inputRef: inputRef,
51
+ placeholder: PLACEHOLDER,
52
+ placeholderTextColor: colors.textColorDefaultPlaceholder,
53
+ accessibilityLabel: PLACEHOLDER,
54
+ value: term,
55
+ onChangeText: onChange,
56
+ returnKeyType: "search",
57
+ style: styles.input
58
+ });
59
+ $[4] = colors.textColorDefaultPlaceholder;
60
+ $[5] = onChange;
61
+ $[6] = styles.input;
62
+ $[7] = term;
63
+ $[8] = t3;
64
+ } else {
65
+ t3 = $[8];
66
+ }
67
+ let t4;
68
+ if ($[9] !== clear || $[10] !== colors.iconColorDefaultSecondary || $[11] !== term.length) {
69
+ t4 = term.length > 0 && /*#__PURE__*/_jsx(Pressable, {
70
+ onPress: clear,
71
+ hitSlop: 8,
72
+ accessibilityRole: "button",
73
+ accessibilityLabel: "Clear search",
74
+ children: /*#__PURE__*/_jsx(Icon, {
75
+ name: "general.x",
76
+ size: 12,
77
+ color: colors.iconColorDefaultSecondary
78
+ })
79
+ });
80
+ $[9] = clear;
81
+ $[10] = colors.iconColorDefaultSecondary;
82
+ $[11] = term.length;
83
+ $[12] = t4;
84
+ } else {
85
+ t4 = $[12];
86
+ }
87
+ let t5;
88
+ if ($[13] !== styles.field || $[14] !== t2 || $[15] !== t3 || $[16] !== t4) {
89
+ t5 = /*#__PURE__*/_jsxs(View, {
90
+ style: styles.field,
91
+ children: [t2, t3, t4]
92
+ });
93
+ $[13] = styles.field;
94
+ $[14] = t2;
95
+ $[15] = t3;
96
+ $[16] = t4;
97
+ $[17] = t5;
98
+ } else {
99
+ t5 = $[17];
100
+ }
101
+ let t6;
102
+ if ($[18] !== styles.container || $[19] !== t5) {
103
+ t6 = /*#__PURE__*/_jsx(View, {
104
+ style: styles.container,
105
+ children: t5
106
+ });
107
+ $[18] = styles.container;
108
+ $[19] = t5;
109
+ $[20] = t6;
110
+ } else {
111
+ t6 = $[20];
112
+ }
113
+ return t6;
114
+ }
115
+ const useStyles = () => {
116
+ const $ = _c(3);
117
+ const {
118
+ colors
119
+ } = useTheme();
120
+ let t0;
121
+ if ($[0] !== colors.borderColorDefaultBase || $[1] !== colors.textColorDefaultPrimary) {
122
+ t0 = StyleSheet.create({
123
+ container: {
124
+ paddingHorizontal: 16,
125
+ paddingVertical: 8
126
+ },
127
+ field: {
128
+ flexDirection: "row",
129
+ alignItems: "center",
130
+ gap: 8,
131
+ borderWidth: 1,
132
+ borderColor: colors.borderColorDefaultBase,
133
+ borderRadius: 8,
134
+ paddingHorizontal: 12,
135
+ paddingVertical: 8
136
+ },
137
+ input: {
138
+ flex: 1,
139
+ color: colors.textColorDefaultPrimary,
140
+ fontSize: 16,
141
+ paddingVertical: 2
142
+ }
143
+ });
144
+ $[0] = colors.borderColorDefaultBase;
145
+ $[1] = colors.textColorDefaultPrimary;
146
+ $[2] = t0;
147
+ } else {
148
+ t0 = $[2];
149
+ }
150
+ return t0;
151
+ };
152
+ //# sourceMappingURL=search_field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_field.js","names":["useRef","Pressable","StyleSheet","View","Icon","AutoFocusAwareTextInput","useTheme","jsx","_jsx","jsxs","_jsxs","PLACEHOLDER","SearchField","t0","$","_c","term","onChange","styles","useStyles","colors","inputRef","t1","current","clear","focus","t2","iconColorDefaultSecondary","name","size","color","t3","textColorDefaultPlaceholder","input","autoFocus","autoCorrect","placeholderTextColor","returnKeyType","style","t4","length","hitSlop","accessibilityRole","accessibilityLabel","children","t5","field","t6","container","borderColorDefaultBase","textColorDefaultPrimary","create","paddingHorizontal","paddingVertical","flexDirection","alignItems","gap","borderWidth","borderColor","borderRadius","flex","fontSize"],"sources":["../../../../src/screens/search/components/search_field.tsx"],"sourcesContent":["import { useRef } from 'react'\nimport { Pressable, StyleSheet, TextInput, View } from 'react-native'\nimport { Icon } from '../../../components'\nimport { AutoFocusAwareTextInput } from '../../../components/display/text_input'\nimport { useTheme } from '../../../hooks'\n\nconst PLACEHOLDER = 'Search titles and messages'\n\ninterface SearchFieldProps {\n term: string\n onChange: (term: string) => void\n}\n\nexport function SearchField({ term, onChange }: SearchFieldProps) {\n const styles = useStyles()\n const { colors } = useTheme()\n const inputRef = useRef<TextInput>(null)\n\n const clear = () => {\n onChange('')\n inputRef.current?.clear()\n inputRef.current?.focus()\n }\n\n return (\n <View style={styles.container}>\n <View style={styles.field}>\n <Icon name=\"general.search\" size={16} color={colors.iconColorDefaultSecondary} />\n <AutoFocusAwareTextInput\n autoFocus\n autoCorrect={false}\n inputRef={inputRef}\n placeholder={PLACEHOLDER}\n placeholderTextColor={colors.textColorDefaultPlaceholder}\n accessibilityLabel={PLACEHOLDER}\n value={term}\n onChangeText={onChange}\n returnKeyType=\"search\"\n style={styles.input}\n />\n {term.length > 0 && (\n <Pressable\n onPress={clear}\n hitSlop={8}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Clear search\"\n >\n <Icon name=\"general.x\" size={12} color={colors.iconColorDefaultSecondary} />\n </Pressable>\n )}\n </View>\n </View>\n )\n}\n\nconst useStyles = () => {\n const { colors } = useTheme()\n\n return StyleSheet.create({\n container: {\n paddingHorizontal: 16,\n paddingVertical: 8,\n },\n field: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 8,\n borderWidth: 1,\n borderColor: colors.borderColorDefaultBase,\n borderRadius: 8,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n input: {\n flex: 1,\n color: colors.textColorDefaultPrimary,\n fontSize: 16,\n paddingVertical: 2,\n },\n })\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A6B,sBAAA,IAAAnC,CAAA,QAAAM,MAAA,CAAA8B,uBAAA;IAEtBrC,EAAA,GAAAX,UAAU,CAAAiD,MAAO,CAAC;MAAAH,SAAA,EACZ;QAAAI,iBAAA,EACU,EAAE;QAAAC,eAAA,EACJ;MACnB,CAAC;MAAAP,KAAA,EACM;QAAAQ,aAAA,EACU,KAAK;QAAAC,UAAA,EACR,QAAQ;QAAAC,GAAA,EACf,CAAC;QAAAC,WAAA,EACO,CAAC;QAAAC,WAAA,EACDtC,MAAM,CAAA6B,sBAAuB;QAAAU,YAAA,EAC5B,CAAC;QAAAP,iBAAA,EACI,EAAE;QAAAC,eAAA,EACJ;MACnB,CAAC;MAAApB,KAAA,EACM;QAAA2B,IAAA,EACC,CAAC;QAAA9B,KAAA,EACAV,MAAM,CAAA8B,uBAAwB;QAAAW,QAAA,EAC3B,EAAE;QAAAR,eAAA,EACK;MACnB;IACF,CAAC,CAAC;IAAAvC,CAAA,MAAAM,MAAA,CAAA6B,sBAAA;IAAAnC,CAAA,MAAAM,MAAA,CAAA8B,uBAAA;IAAApC,CAAA,MAAAD,EAAA;EAAA;IAAAA,EAAA,GAAAC,CAAA;EAAA;EAAA,OArBKD,EAqBL;AAAA,CACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"search_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/search/search_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,gCAAgC,CAAA;AAQvC,eAAO,MAAM,mBAAmB,GAAI,iBAEjC,sBAAsB,CAAC,aAAa,CAAC,KAAG,4BAIxC,CAAA;AAEH,wBAAgB,YAAY,4CAE3B"}
1
+ {"version":3,"file":"search_screen.d.ts","sourceRoot":"","sources":["../../../src/screens/search/search_screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACvB,MAAM,gCAAgC,CAAA;AAUvC,eAAO,MAAM,mBAAmB,GAAI,iBAEjC,sBAAsB,CAAC,aAAa,CAAC,KAAG,4BAIxC,CAAA;AAEH,wBAAgB,YAAY,4CAU3B"}
@@ -1,7 +1,9 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
- import React from 'react';
2
+ import React, { useState } from 'react';
3
3
  import { StyleSheet, View } from 'react-native';
4
+ import { KeyboardView } from '../../components';
4
5
  import { composeOptions, withMinimalBack } from '../../components/display/platform_modal_header_buttons';
6
+ import { SearchField } from './components/search_field';
5
7
  import { jsx as _jsx } from "react/jsx-runtime";
6
8
  export const SearchScreenOptions = ({
7
9
  navigation
@@ -12,16 +14,24 @@ export const SearchScreenOptions = ({
12
14
  onPress: () => navigation.goBack()
13
15
  }));
14
16
  export function SearchScreen() {
15
- const $ = _c(1);
17
+ const $ = _c(2);
18
+ const [term, setTerm] = useState("");
16
19
  let t0;
17
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
18
- t0 = /*#__PURE__*/_jsx(View, {
19
- style: styles.container,
20
- testID: "search-screen"
20
+ if ($[0] !== term) {
21
+ t0 = /*#__PURE__*/_jsx(KeyboardView, {
22
+ children: /*#__PURE__*/_jsx(View, {
23
+ style: styles.container,
24
+ testID: "search-screen",
25
+ children: /*#__PURE__*/_jsx(SearchField, {
26
+ term: term,
27
+ onChange: setTerm
28
+ })
29
+ })
21
30
  });
22
- $[0] = t0;
31
+ $[0] = term;
32
+ $[1] = t0;
23
33
  } else {
24
- t0 = $[0];
34
+ t0 = $[1];
25
35
  }
26
36
  return t0;
27
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"search_screen.js","names":["React","StyleSheet","View","composeOptions","withMinimalBack","jsx","_jsx","SearchScreenOptions","navigation","title","animation","onPress","goBack","SearchScreen","$","_c","t0","Symbol","for","style","styles","container","testID","create","flex"],"sources":["../../../src/screens/search/search_screen.tsx"],"sourcesContent":["import { ParamListBase } from '@react-navigation/native'\nimport {\n NativeStackNavigationOptions,\n NativeStackScreenProps,\n} from '@react-navigation/native-stack'\nimport React from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport {\n composeOptions,\n withMinimalBack,\n} from '../../components/display/platform_modal_header_buttons'\n\nexport const SearchScreenOptions = ({\n navigation,\n}: NativeStackScreenProps<ParamListBase>): NativeStackNavigationOptions =>\n composeOptions(\n { title: 'Search', animation: 'fade' },\n withMinimalBack({ onPress: () => navigation.goBack() })\n )\n\nexport function SearchScreen() {\n return <View style={styles.container} testID=\"search-screen\" />\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n})\n"],"mappings":";AAKA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SACEC,cAAc,EACdC,eAAe,QACV,wDAAwD;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAE/D,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;EAClCC;AACqC,CAAC,KACtCL,cAAc,CACZ;EAAEM,KAAK,EAAE,QAAQ;EAAEC,SAAS,EAAE;AAAO,CAAC,EACtCN,eAAe,CAAC;EAAEO,OAAO,EAAEA,CAAA,KAAMH,UAAU,CAACI,MAAM,CAAC;AAAE,CAAC,CACxD,CAAC;AAEH,OAAO,SAAAC,aAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAF,CAAA,QAAAG,MAAA,CAAAC,GAAA;IACEF,EAAA,gBAAAV,IAAA,CAACJ,IAAI;MAAQiB,KAAgB,EAAhBC,MAAM,CAAAC,SAAU;MAASC,MAAe,EAAf;IAAe,CAAE,CAAC;IAAAR,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAAA,OAAxDE,EAAwD;AAAA;AAGjE,MAAMI,MAAM,GAAGnB,UAAU,CAACsB,MAAM,CAAC;EAC/BF,SAAS,EAAE;IACTG,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"search_screen.js","names":["React","useState","StyleSheet","View","KeyboardView","composeOptions","withMinimalBack","SearchField","jsx","_jsx","SearchScreenOptions","navigation","title","animation","onPress","goBack","SearchScreen","$","_c","term","setTerm","t0","children","style","styles","container","testID","create","flex"],"sources":["../../../src/screens/search/search_screen.tsx"],"sourcesContent":["import { ParamListBase } from '@react-navigation/native'\nimport {\n NativeStackNavigationOptions,\n NativeStackScreenProps,\n} from '@react-navigation/native-stack'\nimport React, { useState } from 'react'\nimport { StyleSheet, View } from 'react-native'\nimport { KeyboardView } from '../../components'\nimport {\n composeOptions,\n withMinimalBack,\n} from '../../components/display/platform_modal_header_buttons'\nimport { SearchField } from './components/search_field'\n\nexport const SearchScreenOptions = ({\n navigation,\n}: NativeStackScreenProps<ParamListBase>): NativeStackNavigationOptions =>\n composeOptions(\n { title: 'Search', animation: 'fade' },\n withMinimalBack({ onPress: () => navigation.goBack() })\n )\n\nexport function SearchScreen() {\n const [term, setTerm] = useState('')\n\n return (\n <KeyboardView>\n <View style={styles.container} testID=\"search-screen\">\n <SearchField term={term} onChange={setTerm} />\n </View>\n </KeyboardView>\n )\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n },\n})\n"],"mappings":";AAKA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACEC,cAAc,EACdC,eAAe,QACV,wDAAwD;AAC/D,SAASC,WAAW,QAAQ,2BAA2B;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEvD,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;EAClCC;AACqC,CAAC,KACtCN,cAAc,CACZ;EAAEO,KAAK,EAAE,QAAQ;EAAEC,SAAS,EAAE;AAAO,CAAC,EACtCP,eAAe,CAAC;EAAEQ,OAAO,EAAEA,CAAA,KAAMH,UAAU,CAACI,MAAM,CAAC;AAAE,CAAC,CACxD,CAAC;AAEH,OAAO,SAAAC,aAAA;EAAA,MAAAC,CAAA,GAAAC,EAAA;EACL,OAAAC,IAAA,EAAAC,OAAA,IAAwBnB,QAAQ,CAAC,EAAE,CAAC;EAAA,IAAAoB,EAAA;EAAA,IAAAJ,CAAA,QAAAE,IAAA;IAGlCE,EAAA,gBAAAZ,IAAA,CAACL,YAAY;MAAAkB,QAAA,eACXb,IAAA,CAACN,IAAI;QAAQoB,KAAgB,EAAhBC,MAAM,CAAAC,SAAU;QAASC,MAAe,EAAf,eAAe;QAAAJ,QAAA,eACnDb,IAAA,CAACF,WAAW;UAAOY,IAAI,EAAJA,IAAI;UAAYC,QAAO,EAAPA;QAAO,CAAG;MAAC,CAC1C;IAAC,CACK,CAAC;IAAAH,CAAA,MAAAE,IAAA;IAAAF,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EAAA,OAJfI,EAIe;AAAA;AAInB,MAAMG,MAAM,GAAGtB,UAAU,CAACyB,MAAM,CAAC;EAC/BF,SAAS,EAAE;IACTG,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "4.3.0-rc.7",
3
+ "version": "4.3.0-rc.8",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -84,5 +84,5 @@
84
84
  "sf-symbols-typescript": "^2.2.0",
85
85
  "typescript": "~6.0.3"
86
86
  },
87
- "gitHead": "0709c9d5b579af4f138ca1fd067b4e7f180768a6"
87
+ "gitHead": "9d2cec9da1b024a2b572d2b0cd07efd62a9460be"
88
88
  }
@@ -0,0 +1,29 @@
1
+ import { fireEvent, render } from '@testing-library/react-native'
2
+ import React from 'react'
3
+ import { SearchField } from '../search_field'
4
+
5
+ const inputLabel = 'Search titles and messages'
6
+ const clearLabel = 'Clear search'
7
+
8
+ describe('SearchField', () => {
9
+ it('reports typed text through onChange', () => {
10
+ const onChange = jest.fn()
11
+ const view = render(<SearchField term="" onChange={onChange} />)
12
+
13
+ fireEvent.changeText(view.getByLabelText(inputLabel), 'budget')
14
+
15
+ expect(onChange).toHaveBeenCalledWith('budget')
16
+ })
17
+
18
+ it('shows the clear button only for a non-empty term and clears on press', () => {
19
+ const onChange = jest.fn()
20
+ const view = render(<SearchField term="" onChange={onChange} />)
21
+
22
+ expect(view.queryByLabelText(clearLabel)).toBeNull()
23
+
24
+ view.rerender(<SearchField term="budget" onChange={onChange} />)
25
+ fireEvent.press(view.getByLabelText(clearLabel))
26
+
27
+ expect(onChange).toHaveBeenCalledWith('')
28
+ })
29
+ })
@@ -0,0 +1,81 @@
1
+ import { useRef } from 'react'
2
+ import { Pressable, StyleSheet, TextInput, View } from 'react-native'
3
+ import { Icon } from '../../../components'
4
+ import { AutoFocusAwareTextInput } from '../../../components/display/text_input'
5
+ import { useTheme } from '../../../hooks'
6
+
7
+ const PLACEHOLDER = 'Search titles and messages'
8
+
9
+ interface SearchFieldProps {
10
+ term: string
11
+ onChange: (term: string) => void
12
+ }
13
+
14
+ export function SearchField({ term, onChange }: SearchFieldProps) {
15
+ const styles = useStyles()
16
+ const { colors } = useTheme()
17
+ const inputRef = useRef<TextInput>(null)
18
+
19
+ const clear = () => {
20
+ onChange('')
21
+ inputRef.current?.clear()
22
+ inputRef.current?.focus()
23
+ }
24
+
25
+ return (
26
+ <View style={styles.container}>
27
+ <View style={styles.field}>
28
+ <Icon name="general.search" size={16} color={colors.iconColorDefaultSecondary} />
29
+ <AutoFocusAwareTextInput
30
+ autoFocus
31
+ autoCorrect={false}
32
+ inputRef={inputRef}
33
+ placeholder={PLACEHOLDER}
34
+ placeholderTextColor={colors.textColorDefaultPlaceholder}
35
+ accessibilityLabel={PLACEHOLDER}
36
+ value={term}
37
+ onChangeText={onChange}
38
+ returnKeyType="search"
39
+ style={styles.input}
40
+ />
41
+ {term.length > 0 && (
42
+ <Pressable
43
+ onPress={clear}
44
+ hitSlop={8}
45
+ accessibilityRole="button"
46
+ accessibilityLabel="Clear search"
47
+ >
48
+ <Icon name="general.x" size={12} color={colors.iconColorDefaultSecondary} />
49
+ </Pressable>
50
+ )}
51
+ </View>
52
+ </View>
53
+ )
54
+ }
55
+
56
+ const useStyles = () => {
57
+ const { colors } = useTheme()
58
+
59
+ return StyleSheet.create({
60
+ container: {
61
+ paddingHorizontal: 16,
62
+ paddingVertical: 8,
63
+ },
64
+ field: {
65
+ flexDirection: 'row',
66
+ alignItems: 'center',
67
+ gap: 8,
68
+ borderWidth: 1,
69
+ borderColor: colors.borderColorDefaultBase,
70
+ borderRadius: 8,
71
+ paddingHorizontal: 12,
72
+ paddingVertical: 8,
73
+ },
74
+ input: {
75
+ flex: 1,
76
+ color: colors.textColorDefaultPrimary,
77
+ fontSize: 16,
78
+ paddingVertical: 2,
79
+ },
80
+ })
81
+ }
@@ -3,12 +3,14 @@ import {
3
3
  NativeStackNavigationOptions,
4
4
  NativeStackScreenProps,
5
5
  } from '@react-navigation/native-stack'
6
- import React from 'react'
6
+ import React, { useState } from 'react'
7
7
  import { StyleSheet, View } from 'react-native'
8
+ import { KeyboardView } from '../../components'
8
9
  import {
9
10
  composeOptions,
10
11
  withMinimalBack,
11
12
  } from '../../components/display/platform_modal_header_buttons'
13
+ import { SearchField } from './components/search_field'
12
14
 
13
15
  export const SearchScreenOptions = ({
14
16
  navigation,
@@ -19,7 +21,15 @@ export const SearchScreenOptions = ({
19
21
  )
20
22
 
21
23
  export function SearchScreen() {
22
- return <View style={styles.container} testID="search-screen" />
24
+ const [term, setTerm] = useState('')
25
+
26
+ return (
27
+ <KeyboardView>
28
+ <View style={styles.container} testID="search-screen">
29
+ <SearchField term={term} onChange={setTerm} />
30
+ </View>
31
+ </KeyboardView>
32
+ )
23
33
  }
24
34
 
25
35
  const styles = StyleSheet.create({