Browse Source

CHANGE | Animations modals

merge-requests/250/merge
Vitalik 3 years ago
parent
commit
2a9acbb12b
  1. 8
      babel.config.js
  2. 40
      ios/Podfile.lock
  3. 4
      ios/taskme.xcodeproj/project.pbxproj
  4. 68
      package-lock.json
  5. 3
      package.json
  6. 4
      src/App.tsx
  7. 80
      src/modules/taxonomies/smart-components/select-taxonomies-modal/index.tsx
  8. 85
      src/modules/users/smart-components/select-user-modal/index.tsx
  9. 8
      src/shared/components/forms/form-search.component.tsx

8
babel.config.js

@ -1,3 +1,7 @@ @@ -1,3 +1,7 @@
module.exports = {
module.exports = function (api) {
api.cache(true)
return {
presets: ['module:metro-react-native-babel-preset'],
};
plugins: ['react-native-reanimated/plugin'],
}
}

40
ios/Podfile.lock

@ -10,7 +10,7 @@ PODS: @@ -10,7 +10,7 @@ PODS:
- React-jsi (= 0.64.3)
- ReactCommon/turbomodule/core (= 0.64.3)
- glog (0.3.5)
- OneSignal (3.10.0)
- OneSignal (3.10.1)
- OneSignalXCFramework (3.10.0)
- Permission-Camera (3.2.0):
- RNPermissions
@ -317,6 +317,34 @@ PODS: @@ -317,6 +317,34 @@ PODS:
- TOCropViewController
- RNPermissions (3.2.0):
- React-Core
- RNReanimated (2.4.1):
- DoubleConversion
- FBLazyVector
- FBReactNativeSpec
- glog
- RCT-Folly
- RCTRequired
- RCTTypeSafety
- React
- React-callinvoker
- React-Core
- React-Core/DevSupport
- React-Core/RCTWebSocket
- React-CoreModules
- React-cxxreact
- React-jsi
- React-jsiexecutor
- React-jsinspector
- React-RCTActionSheet
- React-RCTAnimation
- React-RCTBlob
- React-RCTImage
- React-RCTLinking
- React-RCTNetwork
- React-RCTSettings
- React-RCTText
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.6.0):
- React-Core
- React-RCTImage
@ -324,7 +352,7 @@ PODS: @@ -324,7 +352,7 @@ PODS:
- React
- RNVectorIcons (8.0.0):
- React-Core
- TOCropViewController (2.6.0)
- TOCropViewController (2.6.1)
- Yoga (1.14.0)
DEPENDENCIES:
@ -378,6 +406,7 @@ DEPENDENCIES: @@ -378,6 +406,7 @@ DEPENDENCIES:
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`)
- RNPermissions (from `../node_modules/react-native-permissions`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
- RNSVG (from `../node_modules/react-native-svg`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
@ -485,6 +514,8 @@ EXTERNAL SOURCES: @@ -485,6 +514,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-image-crop-picker"
RNPermissions:
:path: "../node_modules/react-native-permissions"
RNReanimated:
:path: "../node_modules/react-native-reanimated"
RNScreens:
:path: "../node_modules/react-native-screens"
RNSVG:
@ -500,7 +531,7 @@ SPEC CHECKSUMS: @@ -500,7 +531,7 @@ SPEC CHECKSUMS:
FBLazyVector: c71c5917ec0ad2de41d5d06a5855f6d5eda06971
FBReactNativeSpec: 50ac84ed135478e1b20e25b4c165cd57b2ce1988
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
OneSignal: 198da4de73fb7bd6e45bc04221a7f16efca057ad
OneSignal: ce7e3c514b016b98211b3d0458de156b8cc82aec
OneSignalXCFramework: 10648e60ff3d335fbffa62d9b44b700b56d49b51
Permission-Camera: 9eb618fd601ae4a674b072c3b0d37f109d7b91e5
Permission-PhotoLibrary: 900e7e33012bd5e02e5859cb65d5bb2134259c64
@ -545,10 +576,11 @@ SPEC CHECKSUMS: @@ -545,10 +576,11 @@ SPEC CHECKSUMS:
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNImageCropPicker: 448d3c6e923fde3466b49caf3c2457c2a0ba02dd
RNPermissions: bf844d392fe0ecbfbd2e4ae2b88cc32f2f09b369
RNReanimated: 58e7b950e0172235ff8296dd39ec145f9577e301
RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e
RNSVG: 8ba35cbeb385a52fd960fd28db9d7d18b4c2974f
RNVectorIcons: f67a1abce2ec73e62fe4606e8110e95a832bc859
TOCropViewController: 3105367e808b7d3d886a74ff59bf4804e7d3ab38
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
Yoga: e6ecf3fa25af9d4c87e94ad7d5d292eedef49749
PODFILE CHECKSUM: 39216d0b0cefabcff3ab72e7003b18f6ef39a19e

4
ios/taskme.xcodeproj/project.pbxproj

@ -763,7 +763,7 @@ @@ -763,7 +763,7 @@
CODE_SIGN_ENTITLEMENTS = taskme/taskme.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 57;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
@ -801,7 +801,7 @@ @@ -801,7 +801,7 @@
CODE_SIGN_ENTITLEMENTS = taskme/taskme.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 57;
CURRENT_PROJECT_VERSION = 58;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
ENABLE_BITCODE = NO;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";

68
package-lock.json generated

@ -1568,6 +1568,25 @@ @@ -1568,6 +1568,25 @@
"hoist-non-react-statics": "^3.3.0"
}
},
"@gorhom/bottom-sheet": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/@gorhom/bottom-sheet/-/bottom-sheet-4.1.5.tgz",
"integrity": "sha512-3F5P8jK3NXwT2lGwkAdkdLwDVHaRvMZalUTXjK6Ogf0Tki6idffJ3TNlQZlg8k6+OnXAx0+i80f4XaI+J4GFrA==",
"requires": {
"@gorhom/portal": "^1.0.11",
"invariant": "^2.2.4",
"nanoid": "^3.1.20",
"react-native-redash": "^16.1.1"
}
},
"@gorhom/portal": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/@gorhom/portal/-/portal-1.0.12.tgz",
"integrity": "sha512-JOYe85RUwiksgdMbhLWDCLpH3kgFFz+LCu1lnxOMMBQSfAKtL5kkTKVrhtmQ3Lq3lJM2paGnLc4wJrlVuaC5Jw==",
"requires": {
"nanoid": "^3.1.23"
}
},
"@hapi/hoek": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.1.tgz",
@ -2435,6 +2454,11 @@ @@ -2435,6 +2454,11 @@
"hoist-non-react-statics": "^3.3.0"
}
},
"@types/invariant": {
"version": "2.2.35",
"resolved": "https://registry.npmjs.org/@types/invariant/-/invariant-2.2.35.tgz",
"integrity": "sha512-DxX1V9P8zdJPYQat1gHyY0xj3efl8gnMVjiM9iCY6y27lj+PoQWkgjt8jDqmovPqULkKVpKRg8J36iQiA+EtEg=="
},
"@types/istanbul-lib-coverage": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz",
@ -2698,8 +2722,7 @@ @@ -2698,8 +2722,7 @@
"abs-svg-path": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/abs-svg-path/-/abs-svg-path-0.1.1.tgz",
"integrity": "sha1-32Acjo0roQ1KdtYl4japo5wnI78=",
"dev": true
"integrity": "sha1-32Acjo0roQ1KdtYl4japo5wnI78="
},
"absolute-path": {
"version": "0.0.0",
@ -8014,6 +8037,11 @@ @@ -8014,6 +8037,11 @@
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
"dev": true
},
"mockdate": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz",
"integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ=="
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
@ -8227,7 +8255,6 @@ @@ -8227,7 +8255,6 @@
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/normalize-svg-path/-/normalize-svg-path-1.1.0.tgz",
"integrity": "sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==",
"dev": true,
"requires": {
"svg-arc-to-cubic-bezier": "^3.0.0"
}
@ -8592,8 +8619,7 @@ @@ -8592,8 +8619,7 @@
"parse-svg-path": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/parse-svg-path/-/parse-svg-path-0.1.2.tgz",
"integrity": "sha1-en7A0esG+lMlx9PgCbhZoJtdSes=",
"dev": true
"integrity": "sha1-en7A0esG+lMlx9PgCbhZoJtdSes="
},
"parse5": {
"version": "6.0.1",
@ -9318,6 +9344,30 @@ @@ -9318,6 +9344,30 @@
"resolved": "https://registry.npmjs.org/react-native-raw-bottom-sheet/-/react-native-raw-bottom-sheet-2.2.0.tgz",
"integrity": "sha512-qL4JKIqvbcVxbkKzeh51hjV7suoJN3ouxzvLmOg0FBUV1yiJAfEbacjQdtRCI6+OU5pyGFBIifLsTXcFDwHggg=="
},
"react-native-reanimated": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-2.4.1.tgz",
"integrity": "sha512-kvf7ylGlwa5hxMQ+wpPFjQrI2c6eexf53/xRo+dvXBNefGmSYaYR5sFtD0XMMzIPQlkCB9tJ0Pu9+2WCQUY7Cg==",
"requires": {
"@babel/plugin-transform-object-assign": "^7.10.4",
"@types/invariant": "^2.2.35",
"invariant": "^2.2.4",
"lodash.isequal": "^4.5.0",
"mockdate": "^3.0.2",
"react-native-screens": "^3.4.0",
"string-hash-64": "^1.0.3"
}
},
"react-native-redash": {
"version": "16.2.3",
"resolved": "https://registry.npmjs.org/react-native-redash/-/react-native-redash-16.2.3.tgz",
"integrity": "sha512-vSjHA6/mBY3IpDYPish3DlG06PKNLkb/b89hw7nsDM3yxAJ7Db+yMnEL3pp2YsoYblDc3s+0+wBRlvxay4X4vQ==",
"requires": {
"abs-svg-path": "^0.1.1",
"normalize-svg-path": "^1.0.1",
"parse-svg-path": "^0.1.2"
}
},
"react-native-restart": {
"version": "0.0.24",
"resolved": "https://registry.npmjs.org/react-native-restart/-/react-native-restart-0.0.24.tgz",
@ -10690,6 +10740,11 @@ @@ -10690,6 +10740,11 @@
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY="
},
"string-hash-64": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string-hash-64/-/string-hash-64-1.0.3.tgz",
"integrity": "sha512-D5OKWKvDhyVWWn2x5Y9b+37NUllks34q1dCDhk/vYcso9fmhs+Tl3KR/gE4v5UNj2UA35cnX4KdVVGkG1deKqw=="
},
"string-length": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz",
@ -10848,8 +10903,7 @@ @@ -10848,8 +10903,7 @@
"svg-arc-to-cubic-bezier": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/svg-arc-to-cubic-bezier/-/svg-arc-to-cubic-bezier-3.2.0.tgz",
"integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==",
"dev": true
"integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g=="
},
"svg-parser": {
"version": "2.0.4",

3
package.json

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
"dependencies": {
"@bitalikrty/redux-create-reducer": "^1.0.0",
"@expo/react-native-action-sheet": "^3.13.0",
"@gorhom/bottom-sheet": "^4.1.5",
"@react-native-async-storage/async-storage": "^1.15.8",
"@react-native-community/netinfo": "^6.2.1",
"@react-native-community/push-notification-ios": "^1.10.1",
@ -56,6 +57,7 @@ @@ -56,6 +57,7 @@
"react-native-pager-view": "^5.4.4",
"react-native-permissions": "^3.2.0",
"react-native-raw-bottom-sheet": "^2.2.0",
"react-native-reanimated": "^2.4.1",
"react-native-restart": "0.0.24",
"react-native-safe-area-context": "^3.3.0",
"react-native-screens": "^3.6.0",
@ -82,6 +84,7 @@ @@ -82,6 +84,7 @@
"@react-native-community/eslint-config": "^2.0.0",
"@types/lodash": "^4.14.171",
"@types/react-native": "^0.64.12",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-plugin-inline-import": "^3.0.0",
"babel-plugin-module-resolver": "^4.1.0",

4
src/App.tsx

@ -9,6 +9,8 @@ import { LogBox } from 'react-native' @@ -9,6 +9,8 @@ import { LogBox } from 'react-native'
import { appService } from './services/app.service'
import { NetworkProvider } from 'react-native-offline'
import { ActionSheetProvider } from '@expo/react-native-action-sheet'
import 'react-native-gesture-handler'
import { BottomSheetModalProvider } from '@gorhom/bottom-sheet'
LogBox.ignoreLogs(['Warning: ...', 'Require cycle: ...']) // Ignore log notification by message
LogBox.ignoreAllLogs() //Ignore all log notifications
@ -24,7 +26,9 @@ const App: FC = () => { @@ -24,7 +26,9 @@ const App: FC = () => {
<Provider store={store}>
<NetworkProvider>
<ActionSheetProvider>
<BottomSheetModalProvider>
<Navigation />
</BottomSheetModalProvider>
</ActionSheetProvider>
</NetworkProvider>
</Provider>

80
src/modules/taxonomies/smart-components/select-taxonomies-modal/index.tsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'
import React, { useCallback, useMemo, useRef, useState } from 'react'
import _ from 'lodash'
import {
View,
@ -7,7 +7,6 @@ import { @@ -7,7 +7,6 @@ import {
FlatList,
TouchableOpacity,
Dimensions,
Alert,
} from 'react-native'
import RBSheet from 'react-native-raw-bottom-sheet'
import {
@ -18,7 +17,6 @@ import { @@ -18,7 +17,6 @@ import {
SearchForm,
Txt,
useEventsListener,
useKeyboard,
useTheme,
} from '@/shared'
import { useSelector } from 'react-redux'
@ -27,6 +25,11 @@ import { @@ -27,6 +25,11 @@ import {
selectReasonTaxonomies,
} from '@/store/taxonomies'
import { PartialTheme } from '@/shared/themes/interfaces'
import {
BottomSheetBackdrop,
BottomSheetModal,
BottomSheetTextInput,
} from '@gorhom/bottom-sheet'
const screenHeight = Dimensions.get('screen').height
@ -43,11 +46,12 @@ const selectors = { @@ -43,11 +46,12 @@ const selectors = {
export const SelectTaxonomiesModalSmart = () => {
const { styles } = useTheme(createStyles)
const sheetRef = useRef<RBSheet>(null)
const sheetRef = useRef<BottomSheetModal>(null)
const settingsRef = useRef<ISettingsProps>({ callback: null })
const [type, setType] = useState<FetchType>('groups')
const [isFocus, setFocus] = useState(false)
const [modalHeight, setModalHeight] = useState(screenHeight - $size(250))
const [modalHeight, setModalHeight] = useState(screenHeight - $size(150))
const [selectedItem, selectItem] = useState<ITaxonomyShortInfo>({} as any)
const [searchString, setsearchString] = useState<string>()
@ -77,7 +81,7 @@ export const SelectTaxonomiesModalSmart = () => { @@ -77,7 +81,7 @@ export const SelectTaxonomiesModalSmart = () => {
setType(_.defaultTo(data.type, 'groups'))
selectItem(data.selectedOption)
sheetRef.current.open()
sheetRef.current.present()
} catch (e) {
console.log(e)
}
@ -88,7 +92,6 @@ export const SelectTaxonomiesModalSmart = () => { @@ -88,7 +92,6 @@ export const SelectTaxonomiesModalSmart = () => {
const onClose = () => {
selectItem({} as any)
setsearchString('')
setModalHeight(screenHeight - $size(250))
}
const confirm = () => {
@ -133,34 +136,41 @@ export const SelectTaxonomiesModalSmart = () => { @@ -133,34 +136,41 @@ export const SelectTaxonomiesModalSmart = () => {
searchValue={searchString}
placeholder="Пошук"
onChange={setsearchString}
onFocus={() =>
setModalHeight(screenHeight - 220 - $size(100))
}
onBlur={() => setModalHeight(screenHeight - $size(250))}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
paddingHorizontal={0}
borderBottom={false}
customInputComponent={BottomSheetTextInput}
/>
</View>
)
}
const renderBackdrop = useCallback(
props => (
<BottomSheetBackdrop
{...props}
disappearsOnIndex={-1}
appearsOnIndex={0}
/>
),
[],
)
return (
<RBSheet
<BottomSheetModal
name="select-user-modal"
index={0}
ref={sheetRef}
height={modalHeight}
dragFromTopOnly={true}
closeOnDragDown={true}
openDuration={250}
closeOnPressBack={true}
closeOnPressMask={true}
onClose={onClose}
customStyles={{
container: { ...styles.container, height: modalHeight },
draggableIcon: {
width: $size(70),
height: $size(2),
},
}}>
snapPoints={[modalHeight]}
backgroundStyle={[
styles.container,
isFocus ? styles.containerFocus : null,
]}
backdropComponent={renderBackdrop}
keyboardBehavior="fillParent"
keyboardBlurBehavior="restore"
handleIndicatorStyle={isFocus ? { display: 'none' } : null}>
<FlatList
style={styles.list}
data={options}
@ -168,8 +178,10 @@ export const SelectTaxonomiesModalSmart = () => { @@ -168,8 +178,10 @@ export const SelectTaxonomiesModalSmart = () => {
ListHeaderComponent={renderHeader()}
stickyHeaderIndices={[0]}
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.listContent}
/>
<View style={styles.content}>
<Button
title="Вибрати"
type="primary"
@ -178,7 +190,8 @@ export const SelectTaxonomiesModalSmart = () => { @@ -178,7 +190,8 @@ export const SelectTaxonomiesModalSmart = () => {
sheetRef.current.close()
}}
/>
</RBSheet>
</View>
</BottomSheetModal>
)
}
@ -187,11 +200,13 @@ const createStyles = (theme: PartialTheme) => @@ -187,11 +200,13 @@ const createStyles = (theme: PartialTheme) =>
container: {
borderTopRightRadius: 35,
borderTopLeftRadius: 35,
paddingHorizontal: $size(20),
paddingBottom: $size(30),
backgroundColor: theme.$layoutBg,
marginTop: isAndroid($size(20), 0),
},
containerFocus: {
borderTopRightRadius: 0,
borderTopLeftRadius: 0,
},
title: {
textAlign: 'center',
paddingVertical: 15,
@ -199,6 +214,13 @@ const createStyles = (theme: PartialTheme) => @@ -199,6 +214,13 @@ const createStyles = (theme: PartialTheme) =>
fontSize: $size(22, 14),
color: theme?.$textPrimary,
},
listContent: {
paddingHorizontal: $size(20),
},
content: {
paddingHorizontal: $size(20),
paddingBottom: $size(30),
},
list: {
flex: 1,
},

85
src/modules/users/smart-components/select-user-modal/index.tsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useRef, useState } from 'react'
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import {
View,
Text,
@ -7,7 +7,6 @@ import { @@ -7,7 +7,6 @@ import {
TouchableOpacity,
Dimensions,
} from 'react-native'
import RBSheet from 'react-native-raw-bottom-sheet'
import _ from 'lodash'
import { contactsService, tasksService } from '@/services/domain'
@ -16,6 +15,7 @@ import { @@ -16,6 +15,7 @@ import {
Button,
isAndroid,
IShortUser,
KeyboardSpacer,
SearchForm,
Txt,
useEventsListener,
@ -26,6 +26,11 @@ import { selectUserModalTransforms } from './transforms' @@ -26,6 +26,11 @@ import { selectUserModalTransforms } from './transforms'
import { usersService } from '@/services/domain/users.service'
import { FetchType } from './intefaces'
import { PartialTheme } from '@/shared/themes/interfaces'
import {
BottomSheetModal,
BottomSheetBackdrop,
BottomSheetTextInput,
} from '@gorhom/bottom-sheet'
const screenHeight = Dimensions.get('screen').height
@ -40,13 +45,14 @@ const api = { @@ -40,13 +45,14 @@ const api = {
}
export const SelectUserModalSmart = () => {
const { styles } = useTheme(createStyles)
const sheetRef = useRef<RBSheet>(null)
const { styles, theme } = useTheme(createStyles)
const sheetRef = useRef<BottomSheetModal>(null)
const settingsRef = useRef<ISettingsProps>({ callback: null })
const [type, setType] = useState<FetchType>(null)
const [title, setTitle] = useState<string>('')
const [isFocus, setFocus] = useState(false)
const [modalHeight, setModalHeight] = useState(screenHeight - $size(250))
const [modalHeight, setModalHeight] = useState(screenHeight - 100)
const [selectedItem, selectItem] = useState<IShortUser>({} as any)
const [searchString, setsearchString] = useState<string>()
@ -66,7 +72,7 @@ export const SelectUserModalSmart = () => { @@ -66,7 +72,7 @@ export const SelectUserModalSmart = () => {
callback: data.callback,
}
setType(_.defaultTo(data.type, 'users'))
sheetRef.current.open()
sheetRef.current.present()
if (data.title) setTitle(data.title)
} catch (e) {
console.log(e)
@ -87,6 +93,17 @@ export const SelectUserModalSmart = () => { @@ -87,6 +93,17 @@ export const SelectUserModalSmart = () => {
if (!_.isEmpty(selectedItem)) settingsRef.current.callback(selectedItem)
}
const renderBackdrop = useCallback(
props => (
<BottomSheetBackdrop
{...props}
disappearsOnIndex={-1}
appearsOnIndex={0}
/>
),
[],
)
const renderItem = ({ item }) => {
const isActive = selectedItem.id === item.id
@ -113,36 +130,30 @@ export const SelectUserModalSmart = () => { @@ -113,36 +130,30 @@ export const SelectUserModalSmart = () => {
searchValue={searchString}
placeholder="Пошук"
onChange={setsearchString}
onFocus={() =>
setModalHeight(screenHeight - 220 - $size(100))
}
onBlur={() => setModalHeight(screenHeight - $size(250))}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
paddingHorizontal={0}
borderBottom={false}
customInputComponent={BottomSheetTextInput}
/>
</View>
)
}
return (
<RBSheet
<BottomSheetModal
name="select-user-modal"
index={0}
ref={sheetRef}
height={modalHeight}
dragFromTopOnly={true}
closeOnDragDown={true}
closeOnPressBack={true}
closeOnPressMask={true}
animationType="fade"
onClose={() => {
setModalHeight(screenHeight - $size(250))
}}
customStyles={{
container: { ...styles.container, height: modalHeight },
draggableIcon: {
width: $size(70),
height: $size(2),
},
}}>
snapPoints={[modalHeight]}
backgroundStyle={[
styles.container,
isFocus ? styles.containerFocus : null,
]}
backdropComponent={renderBackdrop}
keyboardBehavior="fillParent"
keyboardBlurBehavior="restore"
handleIndicatorStyle={isFocus ? { display: 'none' } : null}>
<FlatList
style={styles.list}
data={list.items}
@ -151,8 +162,10 @@ export const SelectUserModalSmart = () => { @@ -151,8 +162,10 @@ export const SelectUserModalSmart = () => {
stickyHeaderIndices={[0]}
onEndReached={() => list.loadMore()}
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.listContent}
keyboardShouldPersistTaps="handled"
/>
<View style={styles.content}>
<Button
title="Вибрати"
type="primary"
@ -161,7 +174,8 @@ export const SelectUserModalSmart = () => { @@ -161,7 +174,8 @@ export const SelectUserModalSmart = () => {
sheetRef.current.close()
}}
/>
</RBSheet>
</View>
</BottomSheetModal>
)
}
@ -170,11 +184,13 @@ const createStyles = (theme: PartialTheme) => @@ -170,11 +184,13 @@ const createStyles = (theme: PartialTheme) =>
container: {
borderTopRightRadius: 35,
borderTopLeftRadius: 35,
paddingHorizontal: $size(20),
paddingBottom: $size(30),
backgroundColor: theme.$layoutBg,
marginTop: isAndroid($size(20), 0),
},
containerFocus: {
borderTopRightRadius: 0,
borderTopLeftRadius: 0,
},
title: {
textAlign: 'center',
paddingVertical: 15,
@ -182,6 +198,13 @@ const createStyles = (theme: PartialTheme) => @@ -182,6 +198,13 @@ const createStyles = (theme: PartialTheme) =>
fontSize: $size(22, 14),
color: theme.$textPrimary,
},
listContent: {
paddingHorizontal: $size(20),
},
content: {
paddingHorizontal: $size(20),
paddingBottom: $size(30),
},
list: {
flex: 1,
},

8
src/shared/components/forms/form-search.component.tsx

@ -25,6 +25,8 @@ interface IProps { @@ -25,6 +25,8 @@ interface IProps {
rightContainerStyle?: ViewStyle
paddingHorizontal?: number
onLayout?: (e: LayoutChangeEvent) => void
customInputComponent?: any
}
export const SearchForm: FC<IProps> = ({
@ -41,6 +43,7 @@ export const SearchForm: FC<IProps> = ({ @@ -41,6 +43,7 @@ export const SearchForm: FC<IProps> = ({
rightContainerStyle,
onLayout,
paddingHorizontal = $size(18, 16),
customInputComponent,
}) => {
const { styles, theme } = useTheme(createStyles)
@ -64,6 +67,8 @@ export const SearchForm: FC<IProps> = ({ @@ -64,6 +67,8 @@ export const SearchForm: FC<IProps> = ({
}
}, [val])
const Input: any = customInputComponent ? customInputComponent : TextInput
return (
<View
onLayout={onLayout}
@ -96,7 +101,8 @@ export const SearchForm: FC<IProps> = ({ @@ -96,7 +101,8 @@ export const SearchForm: FC<IProps> = ({
}
/>
<TextInput
<Input
key="input"
style={styles.input}
onFocus={() => {
setFocus(true)

Loading…
Cancel
Save