Browse Source

CHANGE | Animations modals

merge-requests/250/merge
Vitalik 3 years ago
parent
commit
2a9acbb12b
  1. 10
      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. 6
      src/App.tsx
  7. 96
      src/modules/taxonomies/smart-components/select-taxonomies-modal/index.tsx
  8. 101
      src/modules/users/smart-components/select-user-modal/index.tsx
  9. 8
      src/shared/components/forms/form-search.component.tsx

10
babel.config.js

@ -1,3 +1,7 @@
module.exports = { module.exports = function (api) {
presets: ['module:metro-react-native-babel-preset'], 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:
- React-jsi (= 0.64.3) - React-jsi (= 0.64.3)
- ReactCommon/turbomodule/core (= 0.64.3) - ReactCommon/turbomodule/core (= 0.64.3)
- glog (0.3.5) - glog (0.3.5)
- OneSignal (3.10.0) - OneSignal (3.10.1)
- OneSignalXCFramework (3.10.0) - OneSignalXCFramework (3.10.0)
- Permission-Camera (3.2.0): - Permission-Camera (3.2.0):
- RNPermissions - RNPermissions
@ -317,6 +317,34 @@ PODS:
- TOCropViewController - TOCropViewController
- RNPermissions (3.2.0): - RNPermissions (3.2.0):
- React-Core - 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): - RNScreens (3.6.0):
- React-Core - React-Core
- React-RCTImage - React-RCTImage
@ -324,7 +352,7 @@ PODS:
- React - React
- RNVectorIcons (8.0.0): - RNVectorIcons (8.0.0):
- React-Core - React-Core
- TOCropViewController (2.6.0) - TOCropViewController (2.6.1)
- Yoga (1.14.0) - Yoga (1.14.0)
DEPENDENCIES: DEPENDENCIES:
@ -378,6 +406,7 @@ DEPENDENCIES:
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`) - RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`) - RNImageCropPicker (from `../node_modules/react-native-image-crop-picker`)
- RNPermissions (from `../node_modules/react-native-permissions`) - RNPermissions (from `../node_modules/react-native-permissions`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`) - RNScreens (from `../node_modules/react-native-screens`)
- RNSVG (from `../node_modules/react-native-svg`) - RNSVG (from `../node_modules/react-native-svg`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`) - RNVectorIcons (from `../node_modules/react-native-vector-icons`)
@ -485,6 +514,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-image-crop-picker" :path: "../node_modules/react-native-image-crop-picker"
RNPermissions: RNPermissions:
:path: "../node_modules/react-native-permissions" :path: "../node_modules/react-native-permissions"
RNReanimated:
:path: "../node_modules/react-native-reanimated"
RNScreens: RNScreens:
:path: "../node_modules/react-native-screens" :path: "../node_modules/react-native-screens"
RNSVG: RNSVG:
@ -500,7 +531,7 @@ SPEC CHECKSUMS:
FBLazyVector: c71c5917ec0ad2de41d5d06a5855f6d5eda06971 FBLazyVector: c71c5917ec0ad2de41d5d06a5855f6d5eda06971
FBReactNativeSpec: 50ac84ed135478e1b20e25b4c165cd57b2ce1988 FBReactNativeSpec: 50ac84ed135478e1b20e25b4c165cd57b2ce1988
glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62
OneSignal: 198da4de73fb7bd6e45bc04221a7f16efca057ad OneSignal: ce7e3c514b016b98211b3d0458de156b8cc82aec
OneSignalXCFramework: 10648e60ff3d335fbffa62d9b44b700b56d49b51 OneSignalXCFramework: 10648e60ff3d335fbffa62d9b44b700b56d49b51
Permission-Camera: 9eb618fd601ae4a674b072c3b0d37f109d7b91e5 Permission-Camera: 9eb618fd601ae4a674b072c3b0d37f109d7b91e5
Permission-PhotoLibrary: 900e7e33012bd5e02e5859cb65d5bb2134259c64 Permission-PhotoLibrary: 900e7e33012bd5e02e5859cb65d5bb2134259c64
@ -545,10 +576,11 @@ SPEC CHECKSUMS:
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211 RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNImageCropPicker: 448d3c6e923fde3466b49caf3c2457c2a0ba02dd RNImageCropPicker: 448d3c6e923fde3466b49caf3c2457c2a0ba02dd
RNPermissions: bf844d392fe0ecbfbd2e4ae2b88cc32f2f09b369 RNPermissions: bf844d392fe0ecbfbd2e4ae2b88cc32f2f09b369
RNReanimated: 58e7b950e0172235ff8296dd39ec145f9577e301
RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e RNScreens: eb0dfb2d6b21d2d7f980ad46b14eb306d2f1062e
RNSVG: 8ba35cbeb385a52fd960fd28db9d7d18b4c2974f RNSVG: 8ba35cbeb385a52fd960fd28db9d7d18b4c2974f
RNVectorIcons: f67a1abce2ec73e62fe4606e8110e95a832bc859 RNVectorIcons: f67a1abce2ec73e62fe4606e8110e95a832bc859
TOCropViewController: 3105367e808b7d3d886a74ff59bf4804e7d3ab38 TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
Yoga: e6ecf3fa25af9d4c87e94ad7d5d292eedef49749 Yoga: e6ecf3fa25af9d4c87e94ad7d5d292eedef49749
PODFILE CHECKSUM: 39216d0b0cefabcff3ab72e7003b18f6ef39a19e PODFILE CHECKSUM: 39216d0b0cefabcff3ab72e7003b18f6ef39a19e

4
ios/taskme.xcodeproj/project.pbxproj

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

68
package-lock.json generated

@ -1568,6 +1568,25 @@
"hoist-non-react-statics": "^3.3.0" "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": { "@hapi/hoek": {
"version": "9.2.1", "version": "9.2.1",
"resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.1.tgz", "resolved": "https://registry.npmjs.org/@hapi/hoek/-/hoek-9.2.1.tgz",
@ -2435,6 +2454,11 @@
"hoist-non-react-statics": "^3.3.0" "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": { "@types/istanbul-lib-coverage": {
"version": "2.0.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz",
@ -2698,8 +2722,7 @@
"abs-svg-path": { "abs-svg-path": {
"version": "0.1.1", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/abs-svg-path/-/abs-svg-path-0.1.1.tgz", "resolved": "https://registry.npmjs.org/abs-svg-path/-/abs-svg-path-0.1.1.tgz",
"integrity": "sha1-32Acjo0roQ1KdtYl4japo5wnI78=", "integrity": "sha1-32Acjo0roQ1KdtYl4japo5wnI78="
"dev": true
}, },
"absolute-path": { "absolute-path": {
"version": "0.0.0", "version": "0.0.0",
@ -8014,6 +8037,11 @@
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
"dev": true "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": { "moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
@ -8227,7 +8255,6 @@
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/normalize-svg-path/-/normalize-svg-path-1.1.0.tgz", "resolved": "https://registry.npmjs.org/normalize-svg-path/-/normalize-svg-path-1.1.0.tgz",
"integrity": "sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==", "integrity": "sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==",
"dev": true,
"requires": { "requires": {
"svg-arc-to-cubic-bezier": "^3.0.0" "svg-arc-to-cubic-bezier": "^3.0.0"
} }
@ -8592,8 +8619,7 @@
"parse-svg-path": { "parse-svg-path": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/parse-svg-path/-/parse-svg-path-0.1.2.tgz", "resolved": "https://registry.npmjs.org/parse-svg-path/-/parse-svg-path-0.1.2.tgz",
"integrity": "sha1-en7A0esG+lMlx9PgCbhZoJtdSes=", "integrity": "sha1-en7A0esG+lMlx9PgCbhZoJtdSes="
"dev": true
}, },
"parse5": { "parse5": {
"version": "6.0.1", "version": "6.0.1",
@ -9318,6 +9344,30 @@
"resolved": "https://registry.npmjs.org/react-native-raw-bottom-sheet/-/react-native-raw-bottom-sheet-2.2.0.tgz", "resolved": "https://registry.npmjs.org/react-native-raw-bottom-sheet/-/react-native-raw-bottom-sheet-2.2.0.tgz",
"integrity": "sha512-qL4JKIqvbcVxbkKzeh51hjV7suoJN3ouxzvLmOg0FBUV1yiJAfEbacjQdtRCI6+OU5pyGFBIifLsTXcFDwHggg==" "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": { "react-native-restart": {
"version": "0.0.24", "version": "0.0.24",
"resolved": "https://registry.npmjs.org/react-native-restart/-/react-native-restart-0.0.24.tgz", "resolved": "https://registry.npmjs.org/react-native-restart/-/react-native-restart-0.0.24.tgz",
@ -10690,6 +10740,11 @@
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz",
"integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" "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": { "string-length": {
"version": "4.0.2", "version": "4.0.2",
"resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz",
@ -10848,8 +10903,7 @@
"svg-arc-to-cubic-bezier": { "svg-arc-to-cubic-bezier": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/svg-arc-to-cubic-bezier/-/svg-arc-to-cubic-bezier-3.2.0.tgz", "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==", "integrity": "sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g=="
"dev": true
}, },
"svg-parser": { "svg-parser": {
"version": "2.0.4", "version": "2.0.4",

3
package.json

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

6
src/App.tsx

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

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

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

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

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

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

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

Loading…
Cancel
Save