├── .buckconfig ├── .eslintrc.js ├── .flowconfig ├── .gitignore ├── .prettierrc.js ├── .ruby-version ├── .watchmanconfig ├── Gemfile ├── Gemfile.lock ├── README.md ├── __tests__ └── App-test.js ├── android ├── app │ ├── _BUCK │ ├── build.gradle │ ├── build_defs.bzl │ ├── debug.keystore │ ├── proguard-rules.pro │ └── src │ │ ├── debug │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── meispot │ │ │ └── ReactNativeFlipper.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── fonts │ │ │ ├── Jost-Bold.ttf │ │ │ ├── Jost-ExtraLight.ttf │ │ │ ├── Jost-Regular.ttf │ │ │ └── Jost-SemiBold.ttf │ │ ├── java │ │ └── com │ │ │ └── meispot │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── drawable │ │ └── rn_edit_text_material.xml │ │ ├── mipmap-anydpi-v26 │ │ └── ic_launcher.xml │ │ ├── mipmap-hdpi │ │ ├── bootsplash_logo.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_notification.png │ │ ├── mipmap-mdpi │ │ ├── bootsplash_logo.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_notification.png │ │ ├── mipmap-xhdpi │ │ ├── bootsplash_logo.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_notification.png │ │ ├── mipmap-xxhdpi │ │ ├── bootsplash_logo.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_notification.png │ │ ├── mipmap-xxxhdpi │ │ ├── bootsplash_logo.png │ │ ├── ic_launcher.png │ │ ├── ic_launcher_adaptive_back.png │ │ ├── ic_launcher_adaptive_fore.png │ │ └── ic_notification.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── babel.config.js ├── index.js ├── ios ├── Podfile ├── meispot.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── meispot.xcscheme ├── meispot │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── BootSplash.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── BootSplashLogo.imageset │ │ │ ├── Contents.json │ │ │ ├── bootsplash_logo.png │ │ │ ├── bootsplash_logo@2x.png │ │ │ └── bootsplash_logo@3x.png │ │ └── Contents.json │ ├── Info.plist │ ├── LaunchScreen.storyboard │ └── main.m └── meispotTests │ ├── Info.plist │ └── meispotTests.m ├── metro.config.js ├── package-lock.json ├── package.json ├── react-native.config.js ├── src ├── @maps │ ├── Category.ts │ ├── Currency.ts │ ├── Language.ts │ ├── Method.ts │ ├── Status.ts │ └── Unit.ts ├── @types │ ├── auth.d.ts │ ├── env.d.ts │ └── index.d.ts ├── assets │ ├── fonts │ │ ├── Jost-Bold.ttf │ │ ├── Jost-ExtraLight.ttf │ │ ├── Jost-Regular.ttf │ │ └── Jost-SemiBold.ttf │ ├── images │ │ └── splashscreen_image.png │ ├── lottie │ │ ├── database.json │ │ ├── download.json │ │ ├── favorite.json │ │ └── loading.json │ └── svg │ │ ├── analysis.svg │ │ ├── create.svg │ │ ├── forgot.svg │ │ ├── login.svg │ │ ├── register.svg │ │ └── welcome.svg ├── components │ ├── Activities │ │ └── index.tsx │ ├── BackButton │ │ └── index.tsx │ ├── Cards │ │ ├── Actions │ │ │ └── LeftActions │ │ │ │ └── index.tsx │ │ ├── Catalog │ │ │ ├── index.tsx │ │ │ └── observables.ts │ │ ├── Contact │ │ │ ├── index.tsx │ │ │ └── observables.ts │ │ ├── Payment │ │ │ ├── index.tsx │ │ │ └── observables.ts │ │ ├── Task │ │ │ ├── index.tsx │ │ │ └── observables.ts │ │ └── index.tsx │ ├── CustomButton │ │ └── index.tsx │ ├── Empty │ │ └── index.tsx │ ├── FloatButton │ │ └── index.tsx │ ├── Header │ │ └── index.tsx │ ├── Icons │ │ └── index.tsx │ ├── Input │ │ └── index.tsx │ ├── KeyboardAvoidingWrapper │ │ └── index.tsx │ ├── Loading │ │ ├── download.tsx │ │ └── index.tsx │ ├── Pagination │ │ └── index.tsx │ ├── Palette │ │ └── index.tsx │ ├── Progress │ │ └── Vertical │ │ │ └── index.tsx │ ├── Search │ │ └── index.tsx │ ├── Select │ │ ├── Button │ │ │ └── index.tsx │ │ ├── Components │ │ │ └── Label │ │ │ │ └── index.tsx │ │ └── Input │ │ │ └── index.tsx │ └── Shortcuts │ │ ├── index.tsx │ │ └── items.ts ├── constants │ ├── colors.ts │ ├── fonts.ts │ └── index.ts ├── contexts │ ├── auth.tsx │ ├── loading.tsx │ └── manager.tsx ├── database │ ├── index.ts │ ├── migrations │ │ └── index.ts │ ├── models │ │ ├── catalog.ts │ │ ├── contact.ts │ │ ├── index.ts │ │ ├── payment.ts │ │ ├── payment_catalogs.ts │ │ ├── payment_contacts.ts │ │ └── task.ts │ └── schema │ │ └── index.ts ├── hooks │ ├── useAnimation.ts │ ├── useAuth.ts │ ├── useCombinedRefs.ts │ ├── useKeyboard.ts │ └── useManager.ts ├── index.tsx ├── notifications │ ├── index.ts │ └── task.ts ├── routes │ ├── app.routes.tsx │ ├── auth.routes.tsx │ └── index.tsx ├── screens │ ├── auth │ │ ├── login │ │ │ └── index.tsx │ │ ├── register │ │ │ └── index.tsx │ │ └── welcome │ │ │ └── index.tsx │ ├── catalogs │ │ ├── catalog │ │ │ └── index.tsx │ │ └── index.tsx │ ├── contacts │ │ ├── contact │ │ │ └── index.tsx │ │ └── index.tsx │ ├── home │ │ ├── index.tsx │ │ └── tasks.ts │ ├── payments │ │ ├── index.tsx │ │ └── payment │ │ │ ├── contacts │ │ │ ├── contact │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ │ ├── events │ │ │ ├── load │ │ │ │ ├── contacts.ts │ │ │ │ └── orders.ts │ │ │ └── save │ │ │ │ ├── contacts.ts │ │ │ │ └── orders.ts │ │ │ ├── index.tsx │ │ │ └── orders │ │ │ ├── index.tsx │ │ │ └── order │ │ │ └── index.tsx │ ├── resume │ │ ├── index.tsx │ │ └── observables.tsx │ ├── settings │ │ └── index.tsx │ └── tasks │ │ ├── index.tsx │ │ └── task │ │ └── index.tsx ├── services │ └── api.ts ├── skeletons │ ├── card.tsx │ └── home.tsx └── utils │ ├── container.ts │ ├── currency.ts │ ├── index.ts │ └── layout.ts └── tsconfig.json /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; Flow doesn't support platforms 12 | .*/Libraries/Utilities/LoadingView.js 13 | 14 | [untyped] 15 | .*/node_modules/@react-native-community/cli/.*/.* 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/interface.js 21 | node_modules/react-native/flow/ 22 | 23 | [options] 24 | emoji=true 25 | 26 | exact_by_default=true 27 | 28 | format.bracket_spacing=false 29 | 30 | module.file_ext=.js 31 | module.file_ext=.json 32 | module.file_ext=.ios.js 33 | 34 | munge_underscores=true 35 | 36 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 37 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 38 | 39 | suppress_type=$FlowIssue 40 | suppress_type=$FlowFixMe 41 | suppress_type=$FlowFixMeProps 42 | suppress_type=$FlowFixMeState 43 | 44 | [lints] 45 | sketchy-null-number=warn 46 | sketchy-null-mixed=warn 47 | sketchy-number=warn 48 | untyped-type-import=warn 49 | nonstrict-import=warn 50 | deprecated-type=warn 51 | unsafe-getters-setters=warn 52 | unnecessary-invariant=warn 53 | signature-verification-failure=warn 54 | 55 | [strict] 56 | deprecated-type 57 | nonstrict-import 58 | sketchy-null 59 | unclear-type 60 | unsafe-getters-setters 61 | untyped-import 62 | untyped-type-import 63 | 64 | [version] 65 | ^0.162.0 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | *.hprof 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | 59 | # CocoaPods 60 | /ios/Pods/ 61 | 62 | # other 63 | .env 64 | .bundle -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: true, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 2.7.4 2 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version 4 | ruby '2.7.4' 5 | 6 | gem 'cocoapods', '~> 1.11', '>= 1.11.2' 7 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | CFPropertyList (3.0.5) 5 | rexml 6 | activesupport (6.1.5) 7 | concurrent-ruby (~> 1.0, >= 1.0.2) 8 | i18n (>= 1.6, < 2) 9 | minitest (>= 5.1) 10 | tzinfo (~> 2.0) 11 | zeitwerk (~> 2.3) 12 | addressable (2.8.0) 13 | public_suffix (>= 2.0.2, < 5.0) 14 | algoliasearch (1.27.5) 15 | httpclient (~> 2.8, >= 2.8.3) 16 | json (>= 1.5.1) 17 | atomos (0.1.3) 18 | claide (1.1.0) 19 | cocoapods (1.11.3) 20 | addressable (~> 2.8) 21 | claide (>= 1.0.2, < 2.0) 22 | cocoapods-core (= 1.11.3) 23 | cocoapods-deintegrate (>= 1.0.3, < 2.0) 24 | cocoapods-downloader (>= 1.4.0, < 2.0) 25 | cocoapods-plugins (>= 1.0.0, < 2.0) 26 | cocoapods-search (>= 1.0.0, < 2.0) 27 | cocoapods-trunk (>= 1.4.0, < 2.0) 28 | cocoapods-try (>= 1.1.0, < 2.0) 29 | colored2 (~> 3.1) 30 | escape (~> 0.0.4) 31 | fourflusher (>= 2.3.0, < 3.0) 32 | gh_inspector (~> 1.0) 33 | molinillo (~> 0.8.0) 34 | nap (~> 1.0) 35 | ruby-macho (>= 1.0, < 3.0) 36 | xcodeproj (>= 1.21.0, < 2.0) 37 | cocoapods-core (1.11.3) 38 | activesupport (>= 5.0, < 7) 39 | addressable (~> 2.8) 40 | algoliasearch (~> 1.0) 41 | concurrent-ruby (~> 1.1) 42 | fuzzy_match (~> 2.0.4) 43 | nap (~> 1.0) 44 | netrc (~> 0.11) 45 | public_suffix (~> 4.0) 46 | typhoeus (~> 1.0) 47 | cocoapods-deintegrate (1.0.5) 48 | cocoapods-downloader (1.5.1) 49 | cocoapods-plugins (1.0.0) 50 | nap 51 | cocoapods-search (1.0.1) 52 | cocoapods-trunk (1.6.0) 53 | nap (>= 0.8, < 2.0) 54 | netrc (~> 0.11) 55 | cocoapods-try (1.2.0) 56 | colored2 (3.1.2) 57 | concurrent-ruby (1.1.9) 58 | escape (0.0.4) 59 | ethon (0.15.0) 60 | ffi (>= 1.15.0) 61 | ffi (1.15.5) 62 | fourflusher (2.3.1) 63 | fuzzy_match (2.0.4) 64 | gh_inspector (1.1.3) 65 | httpclient (2.8.3) 66 | i18n (1.10.0) 67 | concurrent-ruby (~> 1.0) 68 | json (2.6.1) 69 | minitest (5.15.0) 70 | molinillo (0.8.0) 71 | nanaimo (0.3.0) 72 | nap (1.1.0) 73 | netrc (0.11.0) 74 | public_suffix (4.0.6) 75 | rexml (3.2.5) 76 | ruby-macho (2.5.1) 77 | typhoeus (1.4.0) 78 | ethon (>= 0.9.0) 79 | tzinfo (2.0.4) 80 | concurrent-ruby (~> 1.0) 81 | xcodeproj (1.21.0) 82 | CFPropertyList (>= 2.3.3, < 4.0) 83 | atomos (~> 0.1.3) 84 | claide (>= 1.0.2, < 2.0) 85 | colored2 (~> 3.1) 86 | nanaimo (~> 0.3.0) 87 | rexml (~> 3.2.4) 88 | zeitwerk (2.5.4) 89 | 90 | PLATFORMS 91 | ruby 92 | 93 | DEPENDENCIES 94 | cocoapods (~> 1.11, >= 1.11.2) 95 | 96 | RUBY VERSION 97 | ruby 2.7.4p191 98 | 99 | BUNDLED WITH 100 | 2.2.27 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### Primeira versão do [MEI Spot](https://play.google.com/store/apps/details?id=com.meispot) desenvolvido com a metodologia Offline-First e utiliza as tecnologias _Typescript e React Native_. 2 | 3 |

4 | 5 | 6 | 7 |

8 | 9 | ## **:computer: Tecnologias** 10 | 11 | #### **Mobile** ([React Native](https://reactnative.dev/) + [TypeScript](https://www.typescriptlang.org/)) 12 | 13 | - **[WatermelonDB](https://github.com/Nozbe/WatermelonDB)** 14 | - **[React Navigation](https://reactnavigation.org/)** 15 | - **[Axios](https://github.com/axios/axios)** 16 | 17 | ## **:wine_glass: COMO UTILIZAR** 18 | 19 | Primeiro, você precisa ter o [NodeJS](https://nodejs.org/en/download/) instalado na sua máquina. 20 | 21 | Se você estiver utilizando o **Linux**, você pode optar por instalar o **Node** através do gerênciador de versões [nvm](https://github.com/nvm-sh/nvm) para facilitar o processo de mudança da versão do **Node**, quando for necessário. 22 | 23 | Você pode optar também por utilizar o **yarn** no lugar do **npm**. Você pode instalar clicando neste [link](https://yarnpkg.com/). 24 | 25 | Após ter o **Node** instalado, instale as dependências do **React Native** instale as dependências contidas nos arquivos `package.json` que se encontram na raíz do repositório (para o gerenciamento de commits), no diretório do **app**. Para instalar as dependências, basta abrir o terminal no diretório e digitar o comando: 26 | 27 | ```sh 28 | $ yarn 29 | ou 30 | $ npm install 31 | ``` 32 | 33 | Você precisará criar um arquivo na raíz do projeto chamado **.env** com a chave de requisição da API do servidor [Backend](https://github.com/alenquer/prisma-meispot-v1). 34 | 35 | Dentro do arquivo coloque o URL de seu servidor, em ambiente de desenvolvimento utilize o endereço local da sua máquina: 36 | 37 | ```sh 38 | # exemplo 39 | API_URL="http://192.168.1.22:5000/" 40 | ``` 41 | 42 | Após ter instalado todas as dependências e criado o arquivo com a chave de requisição, você poderá gerar a build do app para o seu dispositivo com: 43 | 44 | ```sh 45 | $ yarn android 46 | ``` 47 | 48 | ### ** :worried: Troubleshoots** 49 | 50 | Cannot read properties of undefined (reading 'transformFile') at Bundler.transformFile 51 | 52 | ```sh 53 | Ran into the same issue with Node.js 17.0.0. To solve it, I downgraded to version 14.18.1, deleted node_modules and reinstalled. 54 | ``` 55 | 56 | ## **:octocat: COMO CONTRIBUIR** 57 | 58 | - Verifique as **Issues** que estão abertas e se já não existe alguma com a sua feature; 59 | - Abra uma **Issue** com o nome e descrição da sua feature e assine com o seu usuário informando que irá fazê-la; 60 | - Faça um **[fork](https://help.github.com/pt/github/getting-started-with-github/fork-a-repo)** do repositório; 61 | - Entre no sua página do GitHub e faça um **clone** do seu **fork**; 62 | - Crie uma _branch_ com o nome da sua feature: `git chechout -b feat/minhaFeature`; 63 | - Faça as alterações necessárias no código ou na documentação; 64 | - Instale as dependências do _commitlint_ na raíz do projeto para a verificação dos commits: `npm install` ou `yarn`; 65 | - Faça o _commit_ das suas alterações seguindo as [convenções de commit](https://www.conventionalcommits.org/pt-br/v1.0.0-beta.4/), adicione na descrição o id da sua Issue em parênteses e lembre de fechar a sua Issue com o id no rodapé do commit: 66 | 67 | ``` 68 | (escopo opcional): (#x) 69 | 70 | [corpo do commit] 71 | 72 | Close #x 73 | ``` 74 | 75 | Exemplo: 76 | 77 | ```sh 78 | feat: adicionado componente para tal coisa (#52) 79 | 80 | Foi adicionado um componente para tal coisa com o objetivo de melhorar tal coisa, deixando o projeto de tal maneira. 81 | 82 | Close #52 83 | ``` 84 | 85 | - Faça um _push_ para a sua _branch_: `git push origin feat/minhaFeature`; 86 | - Agora é só abrir um _pull request_ no repositório que você fez o _fork_ e assim que acontecer o _merge_ sua Issue será fechada e suas alterações irão fazer parte do projeto; 87 | - Depois que o _merge_ da sua pull request for feito, você pode deletar a sua _branch_. 88 | 89 | \* **Obrigado por contribuir!** ❤️ :facepunch: :blush: 90 | -------------------------------------------------------------------------------- /__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.meispot", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.meispot", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/debug.keystore -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | #-keepattributes LineNumberTable,SourceFile 12 | #-renamesourcefileattribute SourceFile 13 | -keep class com.meispot.BuildConfig { *; } 14 | -keep class com.swmansion.reanimated.** { *; } 15 | -keep class com.facebook.react.turbomodule.** { *; } -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/debug/java/com/meispot/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.meispot; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 14 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Jost-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/assets/fonts/Jost-Bold.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Jost-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/assets/fonts/Jost-ExtraLight.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Jost-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/assets/fonts/Jost-Regular.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Jost-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/assets/fonts/Jost-SemiBold.ttf -------------------------------------------------------------------------------- /android/app/src/main/java/com/meispot/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.meispot; 2 | 3 | import android.os.Bundle; 4 | import com.facebook.react.ReactActivity; 5 | import com.facebook.react.ReactActivityDelegate; // <- add this necessary import 6 | import com.zoontek.rnbootsplash.RNBootSplash; // <- add this necessary import 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. This is used to schedule 12 | * rendering of the component. 13 | */ 14 | 15 | @Override 16 | protected void onCreate(Bundle savedInstanceState) { 17 | super.onCreate(null); 18 | } 19 | 20 | @Override 21 | protected String getMainComponentName() { 22 | return "meispot"; 23 | } 24 | 25 | @Override 26 | protected ReactActivityDelegate createReactActivityDelegate() { 27 | return new ReactActivityDelegate(this, getMainComponentName()) { 28 | 29 | @Override 30 | protected void loadApp(String appKey) { 31 | RNBootSplash.init(MainActivity.this); // <- initialize the splash screen 32 | super.loadApp(appKey); 33 | } 34 | }; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/meispot/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.meispot; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | import java.util.Arrays; // ⬅️ This! 15 | import com.facebook.react.bridge.JSIModuleSpec; // ⬅️ This! 16 | import com.facebook.react.bridge.JSIModulePackage; // ⬅️ This! 17 | import com.facebook.react.bridge.ReactApplicationContext; // ⬅️ This! 18 | import com.facebook.react.bridge.JavaScriptContextHolder; // ⬅️ This! 19 | //import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage; // ⬅️ This! 20 | import com.swmansion.reanimated.ReanimatedJSIModulePackage; // <- add 21 | 22 | public class MainApplication extends Application implements ReactApplication { 23 | 24 | private final ReactNativeHost mReactNativeHost = 25 | new ReactNativeHost(this) { 26 | @Override 27 | public boolean getUseDeveloperSupport() { 28 | return BuildConfig.DEBUG; 29 | } 30 | 31 | @Override 32 | protected List getPackages() { 33 | @SuppressWarnings("UnnecessaryLocalVariable") 34 | List packages = new PackageList(this).getPackages(); 35 | // Packages that cannot be autolinked yet can be added manually here, for example: 36 | // packages.add(new MyReactNativePackage()); 37 | return packages; 38 | } 39 | 40 | @Override 41 | protected String getJSMainModuleName() { 42 | return "index"; 43 | } 44 | @Override 45 | protected JSIModulePackage getJSIModulePackage() { 46 | return new JSIModulePackage() { 47 | @Override 48 | public List getJSIModules( 49 | final ReactApplicationContext reactApplicationContext, 50 | final JavaScriptContextHolder jsContext 51 | ) { 52 | List modules = Arrays.asList(); 53 | //modules.addAll(new WatermelonDBJSIPackage().getJSIModules(reactApplicationContext, jsContext)); // ⬅️ This! 54 | modules.addAll(new ReanimatedJSIModulePackage().getJSIModules(reactApplicationContext, jsContext)); // ⬅️ This! 55 | //modules.addAll(new WatermelonDBJSIPackage().getJSIModules(reactApplicationContext, jsContext)); // ⬅️ This! 56 | // ⬅️ add more JSI packages here by conventions above 57 | return modules; 58 | } 59 | }; 60 | } 61 | }; 62 | 63 | @Override 64 | public ReactNativeHost getReactNativeHost() { 65 | return mReactNativeHost; 66 | } 67 | 68 | @Override 69 | public void onCreate() { 70 | super.onCreate(); 71 | SoLoader.init(this, /* native exopackage */ false); 72 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 73 | } 74 | 75 | /** 76 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 77 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 78 | * 79 | * @param context 80 | * @param reactInstanceManager 81 | */ 82 | private static void initializeFlipper( 83 | Context context, ReactInstanceManager reactInstanceManager) { 84 | if (BuildConfig.DEBUG) { 85 | try { 86 | /* 87 | We use reflection here to pick up the class that initializes Flipper, 88 | since Flipper library is not available in release mode 89 | */ 90 | Class aClass = Class.forName("com.meispot.ReactNativeFlipper"); 91 | aClass 92 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 93 | .invoke(null, context, reactInstanceManager); 94 | } catch (ClassNotFoundException e) { 95 | e.printStackTrace(); 96 | } catch (NoSuchMethodException e) { 97 | e.printStackTrace(); 98 | } catch (IllegalAccessException e) { 99 | e.printStackTrace(); 100 | } catch (InvocationTargetException e) { 101 | e.printStackTrace(); 102 | } 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/rn_edit_text_material.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-hdpi/bootsplash_logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-hdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-hdpi/ic_notification.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-mdpi/bootsplash_logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-mdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-mdpi/ic_notification.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xhdpi/bootsplash_logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xhdpi/ic_notification.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxhdpi/bootsplash_logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxhdpi/ic_notification.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxxhdpi/bootsplash_logo.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_back.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_adaptive_fore.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/app/src/main/res/mipmap-xxxhdpi/ic_notification.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | #63ff9f 3 | #FFF 4 | #000000 5 | 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MEI Spot 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "30.0.2" 6 | minSdkVersion = 23 7 | compileSdkVersion = 31 8 | targetSdkVersion = 31 9 | ndkVersion = "20.1.5948944" 10 | kotlinVersion = "1.5.20" 11 | } 12 | repositories { 13 | google() 14 | mavenCentral() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:4.2.2") 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | allprojects { 24 | repositories { 25 | maven { 26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 27 | url("$rootDir/../node_modules/react-native/android") 28 | } 29 | maven { 30 | // Android JSC is installed from npm 31 | url("$rootDir/../node_modules/jsc-android/dist") 32 | } 33 | mavenCentral { 34 | // We don't want to fetch react-native from Maven Central as there are 35 | // older versions over there. 36 | content { 37 | excludeGroup "com.facebook.react" 38 | } 39 | } 40 | google() 41 | maven { url 'https://www.jitpack.io' } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx1024m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.99.0 29 | 30 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 31 | 32 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'meispot' 2 | 3 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 4 | include ':app' 5 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function (api) { 2 | api.cache(true); 3 | return { 4 | presets: [['module:metro-react-native-babel-preset']], 5 | plugins: [ 6 | ['@babel/plugin-proposal-decorators', { legacy: true }], 7 | [ 8 | 'module:react-native-dotenv', 9 | { 10 | moduleName: '@env', 11 | path: '.env', 12 | blocklist: null, 13 | allowlist: null, 14 | allowUndefined: true, 15 | }, 16 | ], 17 | 'react-native-reanimated/plugin', 18 | ], 19 | }; 20 | }; 21 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import { AppRegistry } from 'react-native'; 6 | import { App } from './src'; 7 | 8 | AppRegistry.registerComponent('meispot', () => App); 9 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '11.0' 5 | 6 | target 'meispot' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | target 'meispotTests' do 16 | inherit! :complete 17 | # Pods for testing 18 | end 19 | 20 | # Enables Flipper. 21 | # 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and 23 | # you should disable the next line. 24 | use_flipper!() 25 | 26 | post_install do |installer| 27 | react_native_post_install(installer) 28 | __apply_Xcode_12_5_M1_post_install_workaround(installer) 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /ios/meispot.xcodeproj/xcshareddata/xcschemes/meispot.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /ios/meispot/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/meispot/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"meispot" 37 | initialProperties:nil]; 38 | 39 | if (@available(iOS 13.0, *)) { 40 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 41 | } else { 42 | rootView.backgroundColor = [UIColor whiteColor]; 43 | } 44 | 45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 46 | UIViewController *rootViewController = [UIViewController new]; 47 | rootViewController.view = rootView; 48 | self.window.rootViewController = rootViewController; 49 | [self.window makeKeyAndVisible]; 50 | return YES; 51 | } 52 | 53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 54 | { 55 | #if DEBUG 56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 57 | #else 58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 59 | #endif 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ios/meispot/BootSplash.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/BootSplashLogo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images": [ 3 | { 4 | "idiom": "universal", 5 | "filename": "bootsplash_logo.png", 6 | "scale": "1x" 7 | }, 8 | { 9 | "idiom": "universal", 10 | "filename": "bootsplash_logo@2x.png", 11 | "scale": "2x" 12 | }, 13 | { 14 | "idiom": "universal", 15 | "filename": "bootsplash_logo@3x.png", 16 | "scale": "3x" 17 | } 18 | ], 19 | "info": { 20 | "version": 1, 21 | "author": "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo.png -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@2x.png -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/ios/meispot/Images.xcassets/BootSplashLogo.imageset/bootsplash_logo@3x.png -------------------------------------------------------------------------------- /ios/meispot/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ios/meispot/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | meispot 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSExceptionDomains 30 | 31 | localhost 32 | 33 | NSExceptionAllowsInsecureHTTPLoads 34 | 35 | 36 | 37 | 38 | NSLocationWhenInUseUsageDescription 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIRequiredDeviceCapabilities 43 | 44 | armv7 45 | 46 | UISupportedInterfaceOrientations 47 | 48 | UIInterfaceOrientationPortrait 49 | UIInterfaceOrientationLandscapeLeft 50 | UIInterfaceOrientationLandscapeRight 51 | 52 | UIViewControllerBasedStatusBarAppearance 53 | 54 | UIAppFonts 55 | 56 | Jost-Bold.ttf 57 | Jost-ExtraLight.ttf 58 | Jost-Regular.ttf 59 | Jost-SemiBold.ttf 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /ios/meispot/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ios/meispot/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /ios/meispotTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/meispotTests/meispotTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface meispotTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation meispotTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /metro.config.js: -------------------------------------------------------------------------------- 1 | const { getDefaultConfig } = require('metro-config'); 2 | 3 | module.exports = async () => { 4 | const { 5 | resolver: { sourceExts, assetExts }, 6 | } = await getDefaultConfig(); 7 | return { 8 | transformer: { 9 | babelTransformerPath: require.resolve('react-native-svg-transformer'), 10 | }, 11 | resolver: { 12 | assetExts: assetExts.filter(ext => ext !== 'svg'), 13 | sourceExts: [...sourceExts, 'svg'], 14 | }, 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "meispot", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint ." 11 | }, 12 | "dependencies": { 13 | "@nozbe/watermelondb": "^0.24.0", 14 | "@react-native-async-storage/async-storage": "^1.17.3", 15 | "@react-native-community/datetimepicker": "^6.1.1", 16 | "@react-native-community/netinfo": "^8.2.0", 17 | "@react-native-community/push-notification-ios": "^1.10.1", 18 | "@react-navigation/native": "^6.0.8", 19 | "@react-navigation/native-stack": "^6.5.2", 20 | "axios": "^0.26.1", 21 | "lottie-react-native": "^5.0.1", 22 | "moment": "^2.29.1", 23 | "react": "17.0.2", 24 | "react-hook-form": "^7.29.0", 25 | "react-native": "0.67.4", 26 | "react-native-bootsplash": "^4.1.3", 27 | "react-native-dotenv": "^3.3.1", 28 | "react-native-fast-image": "^8.5.11", 29 | "react-native-gesture-handler": "2.1.1", 30 | "react-native-keychain": "^8.0.0", 31 | "react-native-linear-gradient": "^2.5.6", 32 | "react-native-modal": "^13.0.1", 33 | "react-native-modal-datetime-picker": "^13.1.2", 34 | "react-native-push-notification": "^8.1.1", 35 | "react-native-reanimated": "^2.5.0", 36 | "react-native-safe-area-context": "^4.2.4", 37 | "react-native-screens": "^3.13.1", 38 | "react-native-shimmer-placeholder": "^2.0.8", 39 | "react-native-status-bar-height": "^2.6.0", 40 | "react-native-svg": "^12.3.0", 41 | "react-native-uuid": "^2.0.1", 42 | "react-native-vector-icons": "^9.1.0" 43 | }, 44 | "devDependencies": { 45 | "@babel/core": "^7.12.9", 46 | "@babel/plugin-proposal-decorators": "^7.17.8", 47 | "@babel/runtime": "^7.12.5", 48 | "@react-native-community/eslint-config": "^2.0.0", 49 | "@types/hoist-non-react-statics": "^3.3.1", 50 | "@types/react": "^17.0.43", 51 | "@types/react-native": "^0.67.3", 52 | "@types/react-native-push-notification": "^8.1.0", 53 | "@types/react-native-vector-icons": "^6.4.10", 54 | "babel-jest": "^26.6.3", 55 | "eslint": "7.14.0", 56 | "jest": "^26.6.3", 57 | "metro-react-native-babel-preset": "^0.66.2", 58 | "react-native-svg-transformer": "^1.0.0", 59 | "react-test-renderer": "17.0.2", 60 | "typescript": "^4.6.3" 61 | }, 62 | "jest": { 63 | "preset": "react-native" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /react-native.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | project: { 3 | ios: {}, 4 | android: {}, 5 | }, 6 | assets: ['./src/assets/fonts'], 7 | }; 8 | -------------------------------------------------------------------------------- /src/@maps/Category.ts: -------------------------------------------------------------------------------- 1 | import { Constants } from "../constants"; 2 | 3 | export const Categories = [ 4 | { 5 | name: "Produto", 6 | id: "product", 7 | icon: Constants.CATALOG_PRODUCT_ICON, 8 | }, 9 | { 10 | name: "Material", 11 | id: "material", 12 | icon: Constants.CATALOG_MATERIAL_ICON, 13 | }, 14 | { 15 | name: "Serviço", 16 | id: "service", 17 | icon: Constants.CATALOG_SERVICE_ICON, 18 | }, 19 | ]; 20 | 21 | export default (val: any) => { 22 | const result = Categories.find((e) => e.id === val); 23 | 24 | return ( 25 | result ?? { 26 | id: "", 27 | name: "", 28 | icon: Constants.CATALOGS_ICON, 29 | } 30 | ); 31 | }; 32 | -------------------------------------------------------------------------------- /src/@maps/Currency.ts: -------------------------------------------------------------------------------- 1 | export const CurrencyList = [ 2 | { 3 | id: "BRL", 4 | name: "Brazilian Real (R$)", 5 | }, 6 | ]; 7 | 8 | export default (val: any) => { 9 | const result = CurrencyList.find((e) => e.id === val); 10 | 11 | return ( 12 | result ?? { 13 | id: "USD", 14 | name: "United States Dollar", 15 | } 16 | ); 17 | }; 18 | -------------------------------------------------------------------------------- /src/@maps/Language.ts: -------------------------------------------------------------------------------- 1 | export const Languages = [ 2 | { 3 | id: "pt-br", 4 | name: "Português (BR)", 5 | }, 6 | ]; 7 | 8 | export default (val: any) => { 9 | const result = Languages.find((e) => e.id === val); 10 | 11 | return ( 12 | result ?? { 13 | id: "en", 14 | name: "English", 15 | } 16 | ); 17 | }; 18 | -------------------------------------------------------------------------------- /src/@maps/Method.ts: -------------------------------------------------------------------------------- 1 | export const PayMethods = [ 2 | { 3 | name: "Dinheiro", 4 | id: "money", 5 | }, 6 | { 7 | name: "Pix", 8 | id: "pix", 9 | }, 10 | { 11 | name: "Boleto", 12 | id: "billet", 13 | }, 14 | { 15 | name: "Débito", 16 | id: "debit", 17 | }, 18 | { 19 | name: "Crédito", 20 | id: "credit", 21 | }, 22 | { 23 | name: "Transferência", 24 | id: "transfer", 25 | }, 26 | { 27 | name: "Outros", 28 | id: "other", 29 | }, 30 | ]; 31 | 32 | export default (val: any) => { 33 | const result = PayMethods.find((e) => e.id === val); 34 | 35 | return ( 36 | result ?? { 37 | id: "", 38 | name: "", 39 | } 40 | ); 41 | }; 42 | -------------------------------------------------------------------------------- /src/@maps/Status.ts: -------------------------------------------------------------------------------- 1 | import { Colors } from "../constants/colors"; 2 | 3 | export const StatusList = [ 4 | { 5 | id: "done", 6 | name: "Concluído", 7 | color: Colors.green, 8 | payments: "Vendas concluídas", 9 | }, 10 | { 11 | id: "pending", 12 | name: "Pendente", 13 | color: "orange", 14 | payments: "Vendas pendentes", 15 | }, 16 | { 17 | id: "canceled", 18 | name: "Cancelado", 19 | color: Colors.red, 20 | payments: "Vendas canceladas", 21 | }, 22 | ]; 23 | 24 | export default (val: any) => { 25 | const result = StatusList.find((e) => e.id === val); 26 | 27 | return ( 28 | result ?? { 29 | id: "", 30 | name: "N/A", 31 | color: Colors.green, 32 | payments: "Todas as vendas", 33 | } 34 | ); 35 | }; 36 | -------------------------------------------------------------------------------- /src/@maps/Unit.ts: -------------------------------------------------------------------------------- 1 | export const Units = [ 2 | { 3 | name: "Unidade", 4 | id: "unit", 5 | }, 6 | { 7 | name: "Hora", 8 | id: "hour", 9 | }, 10 | { 11 | name: "Metro", 12 | id: "meter", 13 | }, 14 | { 15 | name: "Kilograma", 16 | id: "kg", 17 | }, 18 | { 19 | name: "Centímetro", 20 | id: "cm", 21 | }, 22 | { 23 | name: "Milímetro", 24 | id: "mm", 25 | }, 26 | { 27 | name: "Litro", 28 | id: "l", 29 | }, 30 | { 31 | name: "Dia", 32 | id: "day", 33 | }, 34 | { 35 | name: "Semana", 36 | id: "week", 37 | }, 38 | ]; 39 | 40 | export default (val: any) => { 41 | const result = Units.find((e) => e.id === val); 42 | 43 | return ( 44 | result ?? { 45 | id: "", 46 | name: "", 47 | } 48 | ); 49 | }; 50 | -------------------------------------------------------------------------------- /src/@types/auth.d.ts: -------------------------------------------------------------------------------- 1 | declare interface IAuthGroup { 2 | id: any; 3 | } 4 | 5 | declare interface IAuthUser { 6 | id: any; 7 | email: string; 8 | username: string; 9 | groups: IAuthGroup[]; 10 | } 11 | 12 | declare interface IAuthContent { 13 | email: string; 14 | username?: string; 15 | password: string; 16 | } 17 | 18 | declare interface IAuthResponse { 19 | user: IAuthUser; 20 | token: string; 21 | error?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/@types/env.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@env' { 2 | export const API_URL: string; 3 | } 4 | -------------------------------------------------------------------------------- /src/@types/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.png'; 2 | 3 | declare interface IStockProps { 4 | catalog_id: any; 5 | relation_id?: any; 6 | value: number; 7 | cost: number; 8 | amount: number; 9 | status?: string; 10 | } 11 | 12 | declare interface ISettings { 13 | language: string; 14 | currency: string; 15 | } 16 | 17 | declare module '*.svg' { 18 | import React from 'react'; 19 | import { SvgProps } from 'react-native-svg'; 20 | const content: React.FC; 21 | export default content; 22 | } 23 | 24 | declare interface IContactProps { 25 | contact_id: any; 26 | relation_id?: any; 27 | status?: string; 28 | } 29 | 30 | declare interface IDiscount { 31 | type: string; 32 | value: number; 33 | } 34 | 35 | declare interface IMethod { 36 | name: string; 37 | } 38 | 39 | declare type IStatus = 'done' | 'pending' | 'canceled' | ''; 40 | 41 | declare interface IFee { 42 | type: string; 43 | value: number; 44 | to: string; 45 | } 46 | 47 | declare type ICatalogCategory = 'product' | 'service' | 'material'; 48 | 49 | declare interface IDeck { 50 | key: string; 51 | render: () => JSX.Element; 52 | isTitle?: boolean; 53 | } 54 | -------------------------------------------------------------------------------- /src/assets/fonts/Jost-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/src/assets/fonts/Jost-Bold.ttf -------------------------------------------------------------------------------- /src/assets/fonts/Jost-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/src/assets/fonts/Jost-ExtraLight.ttf -------------------------------------------------------------------------------- /src/assets/fonts/Jost-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/src/assets/fonts/Jost-Regular.ttf -------------------------------------------------------------------------------- /src/assets/fonts/Jost-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/src/assets/fonts/Jost-SemiBold.ttf -------------------------------------------------------------------------------- /src/assets/images/splashscreen_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alenquer/react-native-meispot/d87ecd56e6baeb5f4c1a48fd0f7cde451e33943c/src/assets/images/splashscreen_image.png -------------------------------------------------------------------------------- /src/assets/lottie/download.json: -------------------------------------------------------------------------------- 1 | {"v":"5.1.8","fr":30,"ip":0,"op":60,"w":256,"h":256,"nm":"Cloud Download","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Arrow","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.334,"y":1},"o":{"x":0.167,"y":0.167},"n":"0p334_1_0p167_0p167","t":0,"s":[128,3,0],"e":[128,138,0],"to":[0,22.5,0],"ti":[0,-41.6666679382324,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.666,"y":0},"n":"0p833_0p833_0p666_0","t":30,"s":[128,138,0],"e":[128,253,0],"to":[0,41.6666679382324,0],"ti":[0,-19.1666660308838,0]},{"t":60}],"ix":2},"a":{"a":0,"k":[128,133,0],"ix":1},"s":{"a":0,"k":[100,-100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[148,138],[148,178],[108,178],[108,138],[78,138],[128,88],[178,138]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":1,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false}],"ip":0,"op":60,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Cloud","tt":2,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[128,128,0],"ix":2},"a":{"a":0,"k":[128,128,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[26,1.8],[36.4,0],[12.5,-24],[0,-30.9],[-33.1,0],[0,0],[0,27.6]],"o":[[-6.8,-34.5],[-28.9,0],[-30.1,3.2],[0,33.1],[0,0],[27.6,0],[0,-26.4]],"v":[[73.5,-19.6],[0,-80],[-66.5,-39.6],[-120,20],[-60,80],[70,80],[120,30]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"Merge Paths 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[128,128],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"bm":0}],"markers":[]} -------------------------------------------------------------------------------- /src/assets/lottie/favorite.json: -------------------------------------------------------------------------------- 1 | {"v":"5.5.7","meta":{"g":"LottieFiles AE 0.1.20","a":"","k":"","d":"","tc":""},"fr":24,"ip":0,"op":27,"w":1900,"h":1900,"nm":"Loading","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[994,1018,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[0,-300.414],[-88.29,-121.52],[-285.711,-92.833],[-142.855,46.417],[-176.579,243.04],[0,150.207],[176.579,243.04],[142.855,46.417],[285.711,-92.833],[88.29,-121.52]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.941712622549,0.877833766563,0.047244322534,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0.753744147806,0.783091406729,0.784834558824,1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":6,"s":[0.753744147806,0.783091406729,0.784834558824,1]},{"t":7,"s":[0.982552111149,0.763284087181,0,1]}],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-60.047,3.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0,0],"y":[1,1]},"o":{"x":[0.227,0.227],"y":[0.013,0.013]},"t":0,"s":[100,100]},{"i":{"x":[0,0],"y":[1.027,1.027]},"o":{"x":[0.645,0.645],"y":[0.021,0.021]},"t":6,"s":[57,57]},{"t":14,"s":[100,100]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Polystar 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":28,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 4","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[926,1018,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":2,"ty":"el","s":{"a":0,"k":[173,173],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.984313726425,0.764705896378,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.167,"y":0.167},"t":8,"s":[0.5,-7.5],"to":[0,-79.284],"ti":[0,79.284]},{"t":20,"s":[0.5,-483.203]}],"ix":2},"a":{"a":0,"k":[3,85],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833],"y":[0.833,0.833]},"o":{"x":[0.654,0.654],"y":[0.042,0.042]},"t":8,"s":[71.537,71.537]},{"t":20,"s":[0,0]}],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"rp","c":{"a":0,"k":10,"ix":1},"o":{"a":0,"k":0,"ix":2},"m":1,"ix":2,"tr":{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":45,"ix":4},"so":{"a":0,"k":100,"ix":5},"eo":{"a":0,"k":100,"ix":6},"nm":"Transform"},"nm":"Repeater 1","mn":"ADBE Vector Filter - Repeater","hd":false}],"ip":8,"op":30,"st":8,"bm":0}],"markers":[]} -------------------------------------------------------------------------------- /src/components/BackButton/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useNavigation } from '@react-navigation/native'; 3 | import { Colors } from '../../constants/colors'; 4 | import { CustomButton } from '../CustomButton'; 5 | 6 | interface Props { 7 | color?: string; 8 | } 9 | 10 | export function BackButton({ color }: Props) { 11 | const { goBack } = useNavigation(); 12 | 13 | return ( 14 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /src/components/Cards/Actions/LeftActions/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, Animated } from 'react-native'; 3 | import { Colors } from '../../../../constants/colors'; 4 | import { ScreenWidth } from '../../../../utils/layout'; 5 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 6 | 7 | export const LeftActions = ( 8 | progress: any, 9 | dragX: Animated.AnimatedInterpolation, 10 | ) => { 11 | return ( 12 | 13 | 34 | 39 | 40 | 41 | ); 42 | }; 43 | -------------------------------------------------------------------------------- /src/components/Cards/Catalog/observables.ts: -------------------------------------------------------------------------------- 1 | import withObservables from '@nozbe/with-observables'; 2 | import { Database, Q } from '@nozbe/watermelondb'; 3 | import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'; 4 | import { ObservedList } from '..'; 5 | 6 | interface IObservables { 7 | filter: string; 8 | database: Database; 9 | } 10 | 11 | const enhance = withObservables( 12 | ['database', 'filter'], 13 | ({ database, filter }: IObservables) => ({ 14 | items: database.collections 15 | .get('catalogs') 16 | .query( 17 | Q.sortBy('star', Q.desc), 18 | Q.sortBy('created_at', Q.desc), 19 | Q.where('name', Q.like(`%${Q.sanitizeLikeString(filter)}%`)), 20 | ), 21 | }), 22 | ); 23 | 24 | export const ObservedCatalogs = withDatabase(enhance(ObservedList)); 25 | -------------------------------------------------------------------------------- /src/components/Cards/Contact/observables.ts: -------------------------------------------------------------------------------- 1 | import withObservables from "@nozbe/with-observables"; 2 | import { Database, Q } from "@nozbe/watermelondb"; 3 | import { withDatabase } from "@nozbe/watermelondb/DatabaseProvider"; 4 | import { ObservedList } from ".."; 5 | 6 | interface IObservables { 7 | data?: any; 8 | filter: string; 9 | database: Database; 10 | } 11 | 12 | const enhance = withObservables( 13 | ['database', 'data', 'filter'], 14 | ({ database, filter }: IObservables) => ({ 15 | items: database.collections 16 | .get('contacts') 17 | .query( 18 | Q.sortBy('star', Q.desc), 19 | Q.sortBy('created_at', Q.desc), 20 | Q.where('name', Q.like(`%${Q.sanitizeLikeString(filter)}%`)), 21 | ), 22 | }), 23 | ); 24 | 25 | export const ObservedContacts = withDatabase(enhance(ObservedList)); 26 | -------------------------------------------------------------------------------- /src/components/Cards/Payment/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef } from 'react'; 2 | import { Alert, Pressable, StyleSheet, Text, View } from 'react-native'; 3 | import { useNavigation } from '@react-navigation/native'; 4 | import { Colors } from '../../../constants/colors'; 5 | import { CustomButton } from '../../CustomButton'; 6 | import { percentageOff } from '../../../utils'; 7 | import { Constants } from '../../../constants'; 8 | import { Fonts } from '../../../constants/fonts'; 9 | import { Swipeable } from 'react-native-gesture-handler'; 10 | import { LeftActions } from '../Actions/LeftActions'; 11 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 12 | import withObservables from '@nozbe/with-observables'; 13 | import useAnimation from '../../../hooks/useAnimation'; 14 | import PaymentCatalogs from '../../../database/models/payment_catalogs'; 15 | import PaymentContacts from '../../../database/models/payment_contacts'; 16 | import Status from '../../../@maps/Status'; 17 | import useAuth from '../../../hooks/useAuth'; 18 | import PaymentModel from '../../../database/models/payment'; 19 | 20 | interface IComponent { 21 | item: PaymentModel; 22 | orders: PaymentCatalogs[]; 23 | contacts: PaymentContacts[]; 24 | } 25 | 26 | const Card: React.FC = ({ item, orders, contacts }) => { 27 | const { formatCurrency } = useAuth(); 28 | const { setAnimation } = useAnimation(); 29 | const navigation = useNavigation(); 30 | 31 | const _ref = useRef(null); 32 | 33 | function estimatedValue() { 34 | return orders 35 | .map((item: any) => (item.value - item.cost) * item.amount) 36 | .reduce((prev: number, next: number) => prev + next, 0); 37 | } 38 | 39 | async function deleteItem() { 40 | if (orders.length > 0 || contacts.length > 0) { 41 | Alert.alert('', 'Não é possível remover um item com vínculos.'); 42 | return _ref.current?.close(); 43 | } 44 | 45 | setAnimation('download'); 46 | 47 | await item.delete(); 48 | 49 | setAnimation(''); 50 | } 51 | 52 | async function go() { 53 | return navigation.navigate('payment' as never, { id: item.id } as never); 54 | } 55 | 56 | let _discount: IDiscount = JSON.parse(item.discount as string); 57 | let _fee: IFee = JSON.parse(item.fee as string); 58 | 59 | return ( 60 | 64 | 68 | 70 | 80 | 81 | 88 | { 89 | formatCurrency( 90 | percentageOff( 91 | _discount.type, 92 | estimatedValue() + item.extra, 93 | _discount.value, 94 | ).toFixed(2), 95 | )[0] 96 | } 97 | 98 | 105 | {item.name} 106 | 107 | 108 | 109 | 114 | 115 | 116 | ); 117 | }; 118 | 119 | export const PaymentCard = withObservables(['item'], ({ item }) => ({ 120 | item, 121 | orders: item.orders, 122 | contacts: item.contacts, 123 | }))(Card); 124 | 125 | const styles = StyleSheet.create({ 126 | container: { 127 | height: Constants.CARD_ITEM_HEIGHT, 128 | paddingHorizontal: 15, 129 | flexDirection: 'row', 130 | alignItems: 'center', 131 | justifyContent: 'space-between', 132 | backgroundColor: 'white', 133 | }, 134 | }); 135 | -------------------------------------------------------------------------------- /src/components/Cards/Payment/observables.ts: -------------------------------------------------------------------------------- 1 | import withObservables from '@nozbe/with-observables'; 2 | import { Database, Q } from '@nozbe/watermelondb'; 3 | import { ObservedList } from '..'; 4 | import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'; 5 | 6 | interface IObservables { 7 | filter: string; 8 | status: string; 9 | database: Database; 10 | } 11 | 12 | const enhance = withObservables( 13 | ['database', 'filter', 'status'], 14 | ({ database, filter, status }: IObservables) => ({ 15 | items: database.collections 16 | .get('payments') 17 | .query( 18 | Q.sortBy('star', Q.desc), 19 | Q.sortBy('created_at', Q.desc), 20 | Q.where('name', Q.like(`%${Q.sanitizeLikeString(filter)}%`)), 21 | Q.where('status', Q.like(`%${Q.sanitizeLikeString(status)}%`)), 22 | ), 23 | }), 24 | ); 25 | 26 | export const ObservedPayments = withDatabase(enhance(ObservedList)); 27 | -------------------------------------------------------------------------------- /src/components/Cards/Task/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useRef } from 'react'; 2 | import withObservables from '@nozbe/with-observables'; 3 | import { Pressable, StyleSheet, Text, View } from 'react-native'; 4 | import { useNavigation } from '@react-navigation/native'; 5 | import { Colors } from '../../../constants/colors'; 6 | import { CustomButton } from '../../CustomButton'; 7 | import { Constants } from '../../../constants'; 8 | import { Swipeable } from 'react-native-gesture-handler'; 9 | import { LeftActions } from '../Actions/LeftActions'; 10 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 11 | import { Fonts } from '../../../constants/fonts'; 12 | import useAnimation from '../../../hooks/useAnimation'; 13 | import TaskModel from '../../../database/models/task'; 14 | import Status from '../../../@maps/Status'; 15 | import PushNotification from 'react-native-push-notification'; 16 | 17 | interface IComponent { 18 | item: TaskModel; 19 | } 20 | 21 | const Card: React.FC = ({ item }) => { 22 | const navigation: any = useNavigation(); 23 | const { setAnimation } = useAnimation(); 24 | 25 | const _ref = useRef(null); 26 | 27 | async function deleteItem() { 28 | setAnimation('loading'); 29 | 30 | try { 31 | PushNotification.getScheduledLocalNotifications(notifications => { 32 | for (let notification of notifications) { 33 | if (notification.data.task_id === item.id) { 34 | PushNotification.cancelLocalNotification(notification.id); 35 | } 36 | } 37 | }); 38 | 39 | await item.delete(); 40 | } catch (e) { 41 | throw new Error('Error on TaskCard()'); 42 | } finally { 43 | setAnimation(''); 44 | } 45 | } 46 | 47 | async function go() { 48 | return navigation.navigate('task', { id: item.id }); 49 | } 50 | 51 | return ( 52 | 56 | 60 | 62 | 72 | 73 | 76 | {item.name} 77 | 78 | 81 | {item.notes !== '' ? item.notes : 'Sem informações adicionais'} 82 | 83 | 84 | 85 | 90 | 91 | 92 | ); 93 | }; 94 | 95 | export const TaskCard = withObservables(['item'], ({ item }) => ({ 96 | item, 97 | }))(Card); 98 | 99 | const styles = StyleSheet.create({ 100 | container: { 101 | height: Constants.CARD_ITEM_HEIGHT, 102 | paddingHorizontal: 15, 103 | flexDirection: 'row', 104 | alignItems: 'center', 105 | backgroundColor: 'white', 106 | justifyContent: 'space-between', 107 | }, 108 | text: { 109 | fontSize: 14, 110 | color: Colors.heading, 111 | }, 112 | }); 113 | -------------------------------------------------------------------------------- /src/components/Cards/Task/observables.ts: -------------------------------------------------------------------------------- 1 | import withObservables from '@nozbe/with-observables'; 2 | import { Database, Q } from '@nozbe/watermelondb'; 3 | import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'; 4 | import { ObservedList } from '..'; 5 | 6 | interface IObservables { 7 | filter: string; 8 | database: Database; 9 | } 10 | 11 | const enhance = withObservables( 12 | ['database', 'filter'], 13 | ({ database, filter }: IObservables) => ({ 14 | items: database.collections 15 | .get('tasks') 16 | .query( 17 | Q.sortBy('star', Q.desc), 18 | Q.sortBy('created_at', Q.desc), 19 | Q.where('name', Q.like(`%${Q.sanitizeLikeString(filter)}%`)), 20 | ), 21 | }), 22 | ); 23 | 24 | export const ObservedTasks = withDatabase(enhance(ObservedList)); 25 | -------------------------------------------------------------------------------- /src/components/CustomButton/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TouchableOpacityProps, TouchableOpacity } from 'react-native'; 3 | import { Colors } from '../../constants/colors'; 4 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 5 | 6 | interface Props extends Omit { 7 | icon: any; 8 | color?: string; 9 | size?: number; 10 | } 11 | 12 | export function CustomButton({ icon, color, size = 24, ...rest }: Props) { 13 | return ( 14 | 17 | 22 | 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/components/Empty/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, View } from 'react-native'; 3 | import { Fonts } from "../../constants/fonts"; 4 | 5 | interface IProps { 6 | horizontal?: number; 7 | } 8 | 9 | export const Empty: React.FC = ({ horizontal = 15 }) => { 10 | return ( 11 | 12 | Nenhum item encontrado 13 | 14 | ); 15 | }; 16 | 17 | const styles = StyleSheet.create({ 18 | container: { 19 | height: 40, 20 | backgroundColor: "#eee", 21 | justifyContent: "center", 22 | paddingHorizontal: 15, 23 | borderRadius: 7, 24 | }, 25 | text: { 26 | color: "grey", 27 | fontFamily: Fonts.text, 28 | fontSize: 14, 29 | }, 30 | }); 31 | -------------------------------------------------------------------------------- /src/components/FloatButton/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 3 | import { StyleSheet, TouchableOpacity } from 'react-native'; 4 | import { Constants } from '../../constants'; 5 | 6 | export function FloatActionButton({ icon, color, onPress }: any) { 7 | return ( 8 | 11 | 12 | 13 | ); 14 | } 15 | 16 | const styles = StyleSheet.create({ 17 | container: { 18 | position: 'absolute', 19 | justifyContent: 'center', 20 | alignItems: 'center', 21 | width: 60, 22 | height: 60, 23 | borderRadius: 999, 24 | shadowOpacity: 0.35, 25 | bottom: Constants.FAB_BOTTOM_POSITION, 26 | right: Constants.FAB_RIGHT_POSITION, 27 | shadowOffset: { width: 0, height: 5 }, 28 | shadowColor: '#000', 29 | shadowRadius: 3, 30 | elevation: 3, 31 | }, 32 | }); 33 | -------------------------------------------------------------------------------- /src/components/Header/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, Text, TouchableOpacityProps, View } from 'react-native'; 3 | import { Constants } from '../../constants'; 4 | import { Colors } from '../../constants/colors'; 5 | import { Fonts } from '../../constants/fonts'; 6 | import { BackButton } from '../BackButton'; 7 | import { CustomButton } from '../CustomButton'; 8 | 9 | interface IHeader extends TouchableOpacityProps { 10 | color?: string; 11 | title: string; 12 | icon: any; 13 | } 14 | 15 | export const Header: React.FC = ({ title, icon, ...rest }) => { 16 | return ( 17 | 18 | 19 | {title} 20 | 21 | 22 | ); 23 | }; 24 | 25 | const styles = StyleSheet.create({ 26 | header: { 27 | flexDirection: 'row', 28 | alignItems: 'center', 29 | padding: 15, 30 | paddingTop: Constants.STATUS_BAR_HEIGHT + 15, 31 | justifyContent: 'space-between', 32 | borderBottomWidth: 1, 33 | borderColor: '#eee', 34 | }, 35 | title: { 36 | fontSize: 16, 37 | fontFamily: Fonts.heading, 38 | color: Colors.heading, 39 | }, 40 | }); 41 | -------------------------------------------------------------------------------- /src/components/Icons/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 3 | import {ScrollView, TouchableOpacity, ScrollViewProps} from 'react-native'; 4 | 5 | interface IProps extends ScrollViewProps { 6 | onChangeSelect: (color: string) => void; 7 | color: string; 8 | size?: number; 9 | icon: any; 10 | } 11 | 12 | export const iconArr = [ 13 | 'folder', 14 | 'cog', 15 | 'star', 16 | 'fire', 17 | 'glass-mug-variant', 18 | 'account', 19 | 'lock', 20 | 'mouse', 21 | ]; 22 | 23 | export function Icons({ 24 | icon, 25 | size = 60, 26 | color, 27 | onChangeSelect, 28 | ...rest 29 | }: IProps) { 30 | return ( 31 | 36 | {iconArr.map((res, i) => { 37 | const selected = res === icon; 38 | 39 | return ( 40 | onChangeSelect(res)} 43 | style={{marginRight: i === iconArr.length - 1 ? 15 : 10}}> 44 | 55 | 56 | ); 57 | })} 58 | 59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /src/components/Input/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { 3 | Animated, 4 | StyleSheet, 5 | TextInput, 6 | TextInputProps, 7 | View, 8 | ViewStyle, 9 | } from 'react-native'; 10 | import { Colors } from '../../constants/colors'; 11 | import { Fonts } from '../../constants/fonts'; 12 | 13 | type HideInputProps = 14 | | 'style' 15 | | 'onEndEditing' 16 | | 'onFocus' 17 | | 'onBlur' 18 | | 'style' 19 | | 'multiline'; 20 | 21 | interface IInput extends Omit { 22 | rightComponent?: JSX.Element; 23 | border?: { top?: number; bottom?: number }; 24 | style?: ViewStyle; 25 | multiline?: boolean; 26 | limit?: number; 27 | } 28 | 29 | const AnimatedTextInput = Animated.createAnimatedComponent(TextInput); 30 | 31 | export default function GroupInput({ 32 | rightComponent, 33 | border, 34 | style, 35 | multiline, 36 | limit = 40, 37 | ...rest 38 | }: IInput) { 39 | const [isFocused, setFocused] = useState(false); 40 | const [animatedValue] = useState(new Animated.Value(0)); 41 | 42 | useEffect(() => { 43 | Animated.timing(animatedValue, { 44 | toValue: isFocused ? 1 : 0, 45 | duration: 200, 46 | useNativeDriver: true, 47 | }).start(); 48 | }, [isFocused]); 49 | 50 | return ( 51 | 59 | setFocused(false)} 65 | onFocus={() => setFocused(true)} 66 | placeholderTextColor="grey" 67 | style={[ 68 | styles.input, 69 | { 70 | marginRight: rightComponent && !multiline ? 15 : 0, 71 | }, 72 | ]} 73 | /> 74 | {!multiline && rightComponent} 75 | 76 | ); 77 | } 78 | 79 | const styles = StyleSheet.create({ 80 | container: { 81 | minHeight: 60, 82 | maxHeight: 120, 83 | flexDirection: 'row', 84 | alignItems: 'center', 85 | backgroundColor: '#fff', 86 | justifyContent: 'space-between', 87 | borderColor: Colors.shape, 88 | paddingHorizontal: 15, 89 | paddingVertical: 5, 90 | borderBottomWidth: 1, 91 | }, 92 | input: { 93 | padding: 0, 94 | fontFamily: Fonts.text, 95 | color: Colors.heading, 96 | fontSize: 14, 97 | width: '100%', 98 | flexShrink: 1, 99 | }, 100 | }); 101 | -------------------------------------------------------------------------------- /src/components/KeyboardAvoidingWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | KeyboardAvoidingView, 4 | ScrollView, 5 | ScrollViewProps, 6 | } from 'react-native'; 7 | 8 | type IOmit = 9 | | 'nestedScrollEnabled' 10 | | 'showsVerticalScrollIndicator' 11 | | 'showsHorizontalScrollIndicator'; 12 | 13 | export const KeyboardAvoidingWrapper: React.FC< 14 | Omit 15 | > = ({ children, ...rest }) => { 16 | return ( 17 | 18 | 23 | {children} 24 | 25 | 26 | ); 27 | }; 28 | -------------------------------------------------------------------------------- /src/components/Loading/download.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LottieView from 'lottie-react-native'; 3 | import loadAnimation from '../../assets/lottie/download.json'; 4 | import { LinearGradient } from 'react-native-linear-gradient'; 5 | import { Constants } from '../../constants'; 6 | import { Colors } from '../../constants/colors'; 7 | 8 | export function Download() { 9 | return ( 10 | 15 | 25 | 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /src/components/Loading/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | import LottieView from 'lottie-react-native'; 4 | import loadAnimation from '../../assets/lottie/loading.json'; 5 | 6 | export default function Loading({ ...rest }) { 7 | return ( 8 | 9 | 15 | 16 | ); 17 | } 18 | 19 | const styles = StyleSheet.create({ 20 | container: { 21 | flex: 1, 22 | backgroundColor: 'white', 23 | justifyContent: 'center', 24 | alignItems: 'center', 25 | }, 26 | }); 27 | -------------------------------------------------------------------------------- /src/components/Pagination/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View, Text } from 'react-native'; 3 | import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; 4 | import { Colors } from '../../constants/colors'; 5 | import { Fonts } from '../../constants/fonts'; 6 | import { CustomButton } from '../CustomButton'; 7 | 8 | export function Pagination({ leftAction, page, totalPages, rightAction }: any) { 9 | return ( 10 | 11 | 17 | 18 | {page} 19 | 20 | = totalPages ? Colors.green_light : Colors.green} 25 | /> 26 | 27 | ); 28 | } 29 | 30 | const styles = StyleSheet.create({ 31 | container: { 32 | //height: 70, 33 | paddingVertical: 5, 34 | flexDirection: 'row', 35 | alignItems: 'center', 36 | justifyContent: 'center', 37 | }, 38 | page: { 39 | fontSize: 16, 40 | color: 'white', 41 | fontFamily: Fonts.heading, 42 | }, 43 | actionButton: { 44 | minWidth: 24, 45 | height: 24, 46 | borderRadius: 20, 47 | paddingHorizontal: 15, 48 | marginHorizontal: 3.2, 49 | backgroundColor: Colors.green, 50 | alignItems: 'center', 51 | justifyContent: 'center', 52 | }, 53 | }); 54 | -------------------------------------------------------------------------------- /src/components/Palette/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { ScrollView, View, ScrollViewProps, StyleSheet } from 'react-native'; 3 | import { Colors } from '../../constants/colors'; 4 | import { TouchableWithoutFeedback } from 'react-native-gesture-handler'; 5 | 6 | interface IProps extends ScrollViewProps { 7 | onChangeSelect: (color: string) => void; 8 | fill?: string; 9 | } 10 | 11 | const colorArr = [Colors.green, 'red', 'purple', 'orange']; 12 | 13 | export function ColorList({ 14 | fill = colorArr[0], 15 | onChangeSelect, 16 | ...rest 17 | }: IProps) { 18 | const [color, setColor] = useState(fill); 19 | 20 | return ( 21 | 26 | {colorArr.map((res, i) => { 27 | return ( 28 | { 31 | setColor(res); 32 | onChangeSelect(res); 33 | }}> 34 | 43 | 44 | ); 45 | })} 46 | 47 | ); 48 | } 49 | 50 | const styles = StyleSheet.create({ 51 | item: { 52 | width: 20, 53 | height: 20, 54 | borderRadius: 10, 55 | marginRight: 10, 56 | }, 57 | }); 58 | -------------------------------------------------------------------------------- /src/components/Progress/Vertical/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useRef, useState } from 'react'; 2 | import { 3 | Animated, 4 | LayoutChangeEvent, 5 | StyleSheet, 6 | View, 7 | ViewProps, 8 | ViewStyle, 9 | } from 'react-native'; 10 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 11 | import { Colors } from '../../../constants/colors'; 12 | 13 | interface IProps extends Omit { 14 | step: any; 15 | steps: any; 16 | color: string; 17 | icon: any; 18 | style?: Omit; 19 | backgroundColor?: string; 20 | } 21 | 22 | export const VerticalProgress: React.FC = ({ 23 | step, 24 | steps, 25 | color, 26 | style, 27 | icon, 28 | backgroundColor = 'rgba(0,0,0,0.1)', 29 | ...rest 30 | }) => { 31 | const [stage, setStage] = useState(0); 32 | const animatedValue = useRef(new Animated.Value(0)).current; 33 | const reactive = useRef(new Animated.Value(0)).current; 34 | 35 | useEffect(() => { 36 | Animated.timing(animatedValue, { 37 | toValue: reactive, 38 | duration: 300, 39 | useNativeDriver: true, 40 | }).start(); 41 | }, []); 42 | 43 | useEffect(() => { 44 | if (step && steps >= step) { 45 | reactive.setValue(stage - (stage * step) / steps); 46 | } else { 47 | reactive.setValue(stage); 48 | } 49 | }, [step, steps, stage]); 50 | 51 | function layout(e: LayoutChangeEvent) { 52 | setStage(e.nativeEvent.layout.height); 53 | } 54 | 55 | return ( 56 | 60 | 71 | 82 | 83 | ); 84 | }; 85 | 86 | const styles = StyleSheet.create({ 87 | container: { 88 | overflow: 'hidden', 89 | marginHorizontal: 5, 90 | height: '100%', 91 | width: 40, 92 | borderRadius: 999, 93 | }, 94 | progress: { 95 | width: '100%', 96 | height: '100%', 97 | position: 'absolute', 98 | bottom: 0, 99 | }, 100 | }); 101 | -------------------------------------------------------------------------------- /src/components/Search/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Controller, useForm } from "react-hook-form"; 3 | import { 4 | Keyboard, 5 | StyleSheet, 6 | TextInput, 7 | TextInputProps, 8 | View, 9 | } from "react-native"; 10 | import { Colors } from "../../constants/colors"; 11 | import { CustomButton } from "../CustomButton"; 12 | 13 | interface Props extends TextInputProps { 14 | onChangeValue: (val: any) => void; 15 | filter?: string; 16 | } 17 | 18 | export function SearchBar({ filter = "", onChangeValue, ...rest }: Props) { 19 | const { control } = useForm(); 20 | 21 | return ( 22 | { 27 | return ( 28 | 29 | 34 | value === filter ? undefined : onChangeValue(value) 35 | } 36 | style={styles.input} 37 | {...rest} 38 | /> 39 | {value !== "" && ( 40 | 50 | )} 51 | 52 | ); 53 | }} 54 | /> 55 | ); 56 | } 57 | 58 | const styles = StyleSheet.create({ 59 | container: { 60 | flexDirection: "row", 61 | alignItems: "center", 62 | backgroundColor: "white", 63 | paddingHorizontal: 15, 64 | borderRadius: 11, 65 | flexShrink: 1, 66 | marginHorizontal: 25, 67 | }, 68 | input: { 69 | flexShrink: 1, 70 | height: 40, 71 | width: "100%", 72 | color: "grey", 73 | fontSize: 14, 74 | }, 75 | }); 76 | -------------------------------------------------------------------------------- /src/components/Select/Button/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { FlatList, StyleSheet, Text, View } from 'react-native'; 3 | import { CustomButton } from '../../CustomButton'; 4 | import { Colors } from '../../../constants/colors'; 5 | import { Fonts } from '../../../constants/fonts'; 6 | import { Constants } from '../../../constants'; 7 | import { FloatActionButton } from '../../FloatButton'; 8 | import ReactNativeModal from 'react-native-modal'; 9 | 10 | interface IItem { 11 | id: any; 12 | name: string; 13 | } 14 | 15 | export interface IOptionComponent { 16 | item: IItem; 17 | selected: string; 18 | change: (id: any, name: string) => any; 19 | } 20 | 21 | interface IProps { 22 | data: any[]; 23 | onChangeSelect: (id: any) => void; 24 | title?: string; 25 | defaultValue?: string; 26 | color: string; 27 | icon: string; 28 | OptionComponent: ({ 29 | item, 30 | selected, 31 | change, 32 | }: IOptionComponent) => JSX.Element; 33 | } 34 | 35 | export const FABSelect: React.FC = ({ 36 | data, 37 | icon, 38 | color, 39 | title = 'Selecionar', 40 | onChangeSelect, 41 | defaultValue = '', 42 | OptionComponent, 43 | }) => { 44 | const [selected, setSelected] = useState(defaultValue); 45 | const [modalVisible, setModalVisible] = useState(false); 46 | 47 | function RenderOption({ item }: any) { 48 | return ( 49 | { 53 | setSelected(id); 54 | }} 55 | /> 56 | ); 57 | } 58 | 59 | function close() { 60 | return setModalVisible(false); 61 | } 62 | 63 | function open() { 64 | setSelected(defaultValue); 65 | return setModalVisible(true); 66 | } 67 | 68 | function save() { 69 | close(); 70 | onChangeSelect(selected); 71 | } 72 | 73 | return ( 74 | <> 75 | 76 | 86 | 92 | 93 | 94 | {title} 95 | 96 | 97 | String(item.id)} 100 | renderItem={({ item }) => } 101 | /> 102 | 103 | 104 | 105 | ); 106 | }; 107 | 108 | const styles = StyleSheet.create({ 109 | header: { 110 | justifyContent: 'space-between', 111 | flexDirection: 'row', 112 | alignItems: 'center', 113 | borderBottomWidth: 1, 114 | borderBottomColor: '#eee', 115 | padding: 15, 116 | }, 117 | headerTitle: { 118 | fontSize: 16, 119 | fontFamily: Fonts.heading, 120 | color: Colors.heading, 121 | }, 122 | }); 123 | -------------------------------------------------------------------------------- /src/components/Select/Components/Label/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 3 | import { Colors } from '../../../../constants/colors'; 4 | import { IOptionComponent } from '../../Input'; 5 | import { Text, TouchableOpacity } from 'react-native'; 6 | import { Fonts } from '../../../../constants/fonts'; 7 | 8 | export function LabelOptions({ item, selected, change }: IOptionComponent) { 9 | const color = (placeholder: string) => 10 | item.id === selected ? Colors.green : placeholder; 11 | 12 | return ( 13 | { 21 | change(item.id, item.name); 22 | }}> 23 | 29 | {item.name} 30 | 31 | 36 | 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /src/components/Select/Input/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useState } from "react"; 2 | import { 3 | FlatList, 4 | StyleSheet, 5 | Text, 6 | TouchableOpacity, 7 | View, 8 | } from "react-native"; 9 | import { CustomButton } from "../../CustomButton"; 10 | import { Colors } from "../../../constants/colors"; 11 | import { Fonts } from "../../../constants/fonts"; 12 | import { Constants } from "../../../constants"; 13 | import ReactNativeModal from "react-native-modal"; 14 | 15 | interface IItem { 16 | id: any; 17 | name: string; 18 | } 19 | 20 | export interface IOptionComponent { 21 | item: IItem; 22 | selected: string; 23 | change(id: any, name: string): () => void; 24 | } 25 | 26 | interface IProps { 27 | data: any[]; 28 | onChangeSelect: (id: any) => void; 29 | text: string; 30 | title?: string; 31 | defaultValue?: string; 32 | OptionComponent: ({ item, selected, change }: any) => JSX.Element; 33 | } 34 | 35 | export const InputSelect: React.FC = ({ 36 | data, 37 | text, 38 | title = "Selecionar", 39 | onChangeSelect, 40 | defaultValue = "", 41 | OptionComponent, 42 | }) => { 43 | const [selected, setSelected] = useState(defaultValue); 44 | const [label, setLabel] = useState(text); 45 | const [mark, setMarked] = useState(text); 46 | const [modalVisible, setModalVisible] = useState(false); 47 | 48 | function RenderOption({ item }: any) { 49 | return ( 50 | { 54 | setSelected(id); 55 | setMarked(name); 56 | }} 57 | /> 58 | ); 59 | } 60 | 61 | function close() { 62 | return setModalVisible(false); 63 | } 64 | 65 | function open() { 66 | setSelected(defaultValue); 67 | return setModalVisible(true); 68 | } 69 | 70 | function save() { 71 | close(); 72 | setLabel(mark); 73 | onChangeSelect(selected); 74 | } 75 | 76 | return ( 77 | 78 | 85 | 86 | {label != "" ? label : "Selecionar"} 87 | 88 | 89 | 90 | 101 | 108 | 109 | 110 | {title} 111 | 112 | 113 | String(item.id)} 116 | renderItem={({ item }) => } 117 | /> 118 | 119 | 120 | 121 | ); 122 | }; 123 | 124 | const styles = StyleSheet.create({ 125 | container: { 126 | maxWidth: 200, 127 | borderColor: "#dadada", 128 | borderWidth: 1, 129 | borderRadius: 5, 130 | flexDirection: "row", 131 | alignItems: "center", 132 | justifyContent: "space-between", 133 | height: 34, 134 | paddingHorizontal: 9, 135 | }, 136 | header: { 137 | justifyContent: "space-between", 138 | flexDirection: "row", 139 | alignItems: "center", 140 | borderBottomWidth: 1, 141 | borderBottomColor: "#eee", 142 | padding: 15, 143 | }, 144 | headerTitle: { 145 | fontSize: 16, 146 | fontFamily: Fonts.heading, 147 | color: Colors.heading, 148 | }, 149 | inputTitle: { 150 | color: "grey", 151 | fontFamily: Fonts.text, 152 | fontSize: 14, 153 | flexShrink: 1, 154 | }, 155 | }); 156 | -------------------------------------------------------------------------------- /src/components/Shortcuts/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | ScrollView, 4 | StyleSheet, 5 | Text, 6 | TouchableOpacity, 7 | View, 8 | ViewStyle, 9 | } from 'react-native'; 10 | import { useNavigation } from '@react-navigation/native'; 11 | import { Colors } from '../../constants/colors'; 12 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 13 | import { Constants } from '../../constants'; 14 | import { Fonts } from '../../constants/fonts'; 15 | import items from './items'; 16 | 17 | export function Shortcuts({ ...rest }: ViewStyle) { 18 | const { navigate }: any = useNavigation(); 19 | 20 | function go(item: any) { 21 | navigate(item.route, { 22 | category: item.route, 23 | }); 24 | } 25 | 26 | return ( 27 | 28 | 33 | {items.map((item, idx) => { 34 | return ( 35 | go(item)}> 42 | 48 | {item.label} 49 | 50 | ); 51 | })} 52 | 53 | 54 | ); 55 | } 56 | 57 | const styles = StyleSheet.create({ 58 | container: { 59 | width: '100%', 60 | }, 61 | itemContainer: { 62 | alignItems: 'center', 63 | }, 64 | icon: { 65 | backgroundColor: Colors.green_light, 66 | padding: Constants.SHORTCUT_ICON_SIZE / 4, 67 | borderRadius: Constants.SHORTCUT_ICON_SIZE / 2, 68 | }, 69 | itemLabel: { 70 | fontFamily: Fonts.text, 71 | fontSize: 12, 72 | color: Colors.green_dark, 73 | marginTop: 2.4, 74 | }, 75 | }); 76 | -------------------------------------------------------------------------------- /src/components/Shortcuts/items.ts: -------------------------------------------------------------------------------- 1 | export default [ 2 | // { 3 | // key: 'adawsda', 4 | // icon: 'magnify', 5 | // label: 'Search', 6 | // }, 7 | { 8 | route: 'resume', 9 | icon: 'chart-timeline-variant', 10 | label: 'Resumo', 11 | }, 12 | { 13 | route: 'tasks', 14 | icon: 'alarm-multiple', 15 | label: 'Tarefas', 16 | }, 17 | { 18 | route: 'contacts', 19 | icon: 'account-group', 20 | label: 'Contatos', 21 | }, 22 | { 23 | route: 'payments', 24 | icon: 'currency-usd', 25 | label: 'Pagamentos', 26 | }, 27 | { 28 | route: 'catalogs', 29 | icon: 'store', 30 | label: 'Catálogo', 31 | }, 32 | { 33 | route: 'settings', 34 | icon: 'cog', 35 | label: 'Ajustes', 36 | }, 37 | ]; 38 | -------------------------------------------------------------------------------- /src/constants/colors.ts: -------------------------------------------------------------------------------- 1 | export const Colors = { 2 | green: "#32B768", 3 | green_dark: "#2B7A4B", 4 | green_light: "#DAF2E4", 5 | green_bright: "#63ff9f", 6 | 7 | heading: "#52665A", 8 | body_dark: "#738078", 9 | body_light: "#AAB2AD", 10 | 11 | background: "#FFFFFF", 12 | shape: "#f0f0f0", 13 | white: "#FFFFFF", 14 | gray: "#CFCFCF", 15 | 16 | blue: "#3D7199", 17 | blue_light: "#EBF6FF", 18 | 19 | red: "#E83F5B", 20 | }; 21 | -------------------------------------------------------------------------------- /src/constants/fonts.ts: -------------------------------------------------------------------------------- 1 | export const Fonts = { 2 | heading: 'Jost-SemiBold', 3 | text: 'Jost-Regular', 4 | bold: 'Jost-Bold', 5 | thin: 'Jost-ExtraLight', 6 | }; 7 | -------------------------------------------------------------------------------- /src/constants/index.ts: -------------------------------------------------------------------------------- 1 | import { getStatusBarHeight } from 'react-native-status-bar-height'; 2 | import { ScreenHeight } from '../utils/layout'; 3 | 4 | export const Constants = { 5 | STATUS_BAR_HEIGHT: getStatusBarHeight(), 6 | HEADER_MIN_HEIGHT: 160, 7 | HEADER_MAX_HEIGHT: 292, 8 | MAX_ITEM_RENDER: 15, 9 | CARD_ITEM_HEIGHT: 70, 10 | INITIAL_ITEM_RENDER: Math.ceil(ScreenHeight(100) / 70), 11 | CARD_ICON_SIZE: 40, 12 | GROUP_ICON_SIZE: 120, 13 | SHORTCUT_ICON_SIZE: 80, 14 | SETTINGS_ICON: 'cog', 15 | FAVORITE_ICON: 'star', 16 | CATALOG_MATERIAL_ICON: 'tools', 17 | CATALOG_SERVICE_ICON: 'account-hard-hat', 18 | CATALOG_PRODUCT_ICON: 'package-variant', 19 | TASKS_ICON: 'alarm-multiple', 20 | CONTACTS_ICON: 'account-group', 21 | PAYMENTS_ICON: 'currency-usd', 22 | CATALOGS_ICON: 'store', 23 | SALES_ICON: 'sale', 24 | ANIMATION_MODAL_DURATION: 300, 25 | CONTACT_PHYSICAL_ICON: 'account', 26 | CONTACT_BUSINESS_ICON: 'domain', 27 | FAB_BOTTOM_POSITION: 20, 28 | FAB_RIGHT_POSITION: 20, 29 | PAGE_ICON_SIZE: 90, 30 | MIN_PASSWORD_LENGTH: 8, 31 | MIN_USERNAME_LENGTH: 3, 32 | }; 33 | -------------------------------------------------------------------------------- /src/contexts/auth.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useState } from 'react'; 2 | import { AxiosResponse } from 'axios'; 3 | import { Alert } from 'react-native'; 4 | 5 | import * as Keychain from 'react-native-keychain'; 6 | import PushNotification from 'react-native-push-notification'; 7 | import AsyncStorage from '@react-native-async-storage/async-storage'; 8 | 9 | import { FormatCurrencyFunction } from '../utils/currency'; 10 | import { api } from '../services/api'; 11 | 12 | import useAnimation from '../hooks/useAnimation'; 13 | 14 | interface AuthContextData { 15 | error: string | undefined; 16 | user: IAuthUser; 17 | settings: ISettings; 18 | setUser: (val: IAuthUser) => void; 19 | setSettings: (val: ISettings) => void; 20 | formatCurrency: (amount: any) => [string, number, string, number]; 21 | signIn(user: IAuthContent): Promise; 22 | signUp(user: IAuthContent): Promise; 23 | signOut(): Promise; 24 | } 25 | 26 | export const AuthContext = createContext( 27 | {} as AuthContextData, 28 | ); 29 | 30 | const initialSettings = { 31 | currency: 'BRL', 32 | language: 'pt-br', 33 | }; 34 | 35 | const initialUser = { 36 | email: '', 37 | username: '', 38 | groups: [{ id: undefined, name: 'default' }], 39 | id: undefined, 40 | }; 41 | 42 | export const AuthProvider: React.FC = ({ children }) => { 43 | const { setAnimation } = useAnimation(); 44 | const [user, setUser] = useState(initialUser); 45 | const [error, setError] = useState(); 46 | const [settings, setSettings] = useState(initialSettings); 47 | 48 | function formatCurrency(amount: any) { 49 | return FormatCurrencyFunction({ amount, code: settings.currency }); 50 | } 51 | 52 | async function signIn(auth: IAuthContent): Promise { 53 | try { 54 | setAnimation('loading'); 55 | 56 | const settings = await AsyncStorage.getItem('@settings'); 57 | const response: AxiosResponse = await api.post( 58 | '/auth/login', 59 | { 60 | email: auth.email.trim(), 61 | password: auth.password, 62 | }, 63 | ); 64 | 65 | if (settings) { 66 | setSettings(JSON.parse(settings)); 67 | } 68 | 69 | if (response.status === 200) { 70 | api.defaults.headers.common.Authorization = `Bearer ${response.data.token}`; 71 | 72 | await Keychain.setGenericPassword(auth.email, auth.password); 73 | 74 | setUser(response.data.user); 75 | } 76 | } catch (e) { 77 | Alert.alert('', 'Algo deu errado, tente novamente!'); 78 | } finally { 79 | setAnimation(''); 80 | } 81 | } 82 | 83 | async function signUp(auth: IAuthContent): Promise { 84 | try { 85 | setAnimation('loading'); 86 | 87 | const settings = await AsyncStorage.getItem('@settings'); 88 | const response: AxiosResponse = await api.post( 89 | '/auth/register', 90 | { 91 | email: auth.email.trim(), 92 | username: auth.username, 93 | password: auth.password, 94 | }, 95 | ); 96 | 97 | if (settings) { 98 | setSettings(JSON.parse(settings)); 99 | } 100 | 101 | if (response.status === 200) { 102 | api.defaults.headers.common.Authorization = `Bearer ${response.data.token}`; 103 | 104 | await Keychain.setGenericPassword(auth.email, auth.password); 105 | 106 | setUser(response.data.user); 107 | } 108 | } catch (e) { 109 | console.log(e); 110 | Alert.alert('', 'Algo deu errado, tente novamente!'); 111 | } finally { 112 | setAnimation(''); 113 | } 114 | } 115 | 116 | async function signOut() { 117 | try { 118 | setAnimation('loading'); 119 | await Keychain.resetGenericPassword(); 120 | await AsyncStorage.multiRemove(['@user']); 121 | } catch (e) { 122 | console.log(e); 123 | Alert.alert('', 'Algo deu errado, tente novamente!'); 124 | } finally { 125 | PushNotification.cancelAllLocalNotifications(); 126 | api.defaults.headers.common.Authorization = ''; 127 | setUser(initialUser); 128 | setAnimation(''); 129 | } 130 | } 131 | 132 | return ( 133 | 145 | {children} 146 | 147 | ); 148 | }; 149 | -------------------------------------------------------------------------------- /src/contexts/loading.tsx: -------------------------------------------------------------------------------- 1 | import React, { createContext, useState } from 'react'; 2 | import { BackHandler, Keyboard, StyleSheet, View } from 'react-native'; 3 | import { sleep } from '../utils'; 4 | import Loading from '../components/Loading'; 5 | 6 | interface ManagerContextData { 7 | setAnimation: (val: string) => Promise; 8 | animation: string; 9 | } 10 | 11 | export const LoadingContext = createContext( 12 | {} as ManagerContextData, 13 | ); 14 | 15 | export const LoadingProvider: React.FC = ({ children }) => { 16 | const [animation, setAnimationType] = useState(''); 17 | 18 | async function setAnimation(val: string) { 19 | Keyboard.dismiss(); 20 | const _back = BackHandler.addEventListener('hardwareBackPress', () => true); 21 | 22 | if (val === '') await sleep(1000); 23 | 24 | setAnimationType(val); 25 | _back.remove(); 26 | } 27 | 28 | function handleAnimation() { 29 | switch (animation) { 30 | case 'download': 31 | return ; 32 | default: 33 | return ; 34 | } 35 | } 36 | 37 | return ( 38 | 43 | {children} 44 | {animation !== '' && ( 45 | {handleAnimation()} 46 | )} 47 | 48 | ); 49 | }; 50 | 51 | const styles = StyleSheet.create({ 52 | container: { 53 | position: 'absolute', 54 | right: 0, 55 | top: 0, 56 | bottom: 0, 57 | left: 0, 58 | }, 59 | }); 60 | -------------------------------------------------------------------------------- /src/database/index.ts: -------------------------------------------------------------------------------- 1 | import SQLiteAdapter from '@nozbe/watermelondb/adapters/sqlite'; 2 | import schema from '../database/schema'; 3 | import migrations from '../database/migrations'; 4 | import models from '../database/models'; 5 | import Database from '@nozbe/watermelondb/Database'; 6 | 7 | export default function CustomDB(id?: string) { 8 | const adapter = new SQLiteAdapter({ 9 | jsi: false, 10 | dbName: id ?? 'default', 11 | schema, 12 | migrations, 13 | }); 14 | 15 | return new Database({ 16 | adapter, 17 | modelClasses: models, 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /src/database/migrations/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | schemaMigrations, 3 | createTable, 4 | addColumns, 5 | } from "@nozbe/watermelondb/Schema/migrations"; 6 | 7 | export default schemaMigrations({ 8 | migrations: [ 9 | // { 10 | // toVersion: 2, 11 | // steps: [ 12 | // createTable({ 13 | // name: "teste", 14 | // columns: [], 15 | // }), 16 | // ], 17 | // }, 18 | ], 19 | }); 20 | -------------------------------------------------------------------------------- /src/database/models/catalog.ts: -------------------------------------------------------------------------------- 1 | import { Model, Q } from '@nozbe/watermelondb'; 2 | import { Associations } from '@nozbe/watermelondb/Model'; 3 | import { 4 | field, 5 | date, 6 | readonly, 7 | relation, 8 | writer, 9 | lazy, 10 | } from '@nozbe/watermelondb/decorators'; 11 | 12 | export default class CatalogModel extends Model { 13 | static table = 'catalogs'; 14 | 15 | static associations: Associations = { 16 | payment_catalogs: { type: 'has_many', foreignKey: 'catalog_id' }, 17 | }; 18 | 19 | @field('name') name!: string; 20 | @field('star') star!: boolean; 21 | @field('description') description!: string; 22 | @field('notes') notes!: string; 23 | @field('value') value!: number; 24 | @field('cost') cost!: number; 25 | @field('code') code!: string; 26 | @field('fill') fill!: string; 27 | //@field("amount") amount!: number; 28 | @field('unit') unit!: string; 29 | //@field("control") control!: boolean; 30 | @field('category') category!: ICatalogCategory; 31 | @readonly @date('created_at') createdAt!: number; 32 | @readonly @date('updated_at') updatedAt!: number; 33 | 34 | @lazy payments = this.collections 35 | .get('payment_catalogs') 36 | .query(Q.where('catalog_id', this.id)); 37 | 38 | @writer async delete() { 39 | await this.markAsDeleted(); // syncable 40 | } 41 | 42 | @writer async setQuantity(val: number) { 43 | await this.update(record => { 44 | //record.amount = val; 45 | }); 46 | } 47 | 48 | @writer async getCatalog() { 49 | return { 50 | id: this.id, 51 | name: this.name, 52 | star: this.star, 53 | notes: this.notes, 54 | category: this.category, 55 | cost: this.cost, 56 | fill: this.fill, 57 | description: this.description, 58 | //amount: this.amount, 59 | unit: this.unit, 60 | value: this.value, 61 | //control: this.control, 62 | code: this.code, 63 | }; 64 | } 65 | 66 | @writer async setUpdate(updateData: this) { 67 | return await this.update(record => { 68 | record.name = updateData.name; 69 | record.category = updateData.category; 70 | record.star = updateData.star; 71 | record.cost = updateData.cost; 72 | record.fill = updateData.fill; 73 | //record.amount = updateData.amount; 74 | record.unit = updateData.unit; 75 | record.value = updateData.value; 76 | record.code = updateData.code; 77 | //record.control = updateData.control; 78 | record.description = updateData.description; 79 | }); 80 | } 81 | 82 | @writer async favorite() { 83 | await this.update(record => { 84 | record.star = !record.star; 85 | }); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/database/models/contact.ts: -------------------------------------------------------------------------------- 1 | import { Model, Q } from '@nozbe/watermelondb'; 2 | import { Associations } from '@nozbe/watermelondb/Model'; 3 | import { 4 | field, 5 | writer, 6 | date, 7 | readonly, 8 | relation, 9 | lazy, 10 | } from '@nozbe/watermelondb/decorators'; 11 | 12 | export default class ContactModel extends Model { 13 | static table = 'contacts'; 14 | 15 | static associations: Associations = { 16 | payment_contacts: { type: 'has_many', foreignKey: 'contact_id' }, 17 | }; 18 | 19 | @field('name') name!: string; 20 | @field('star') star!: boolean; 21 | @field('email') email!: string; 22 | @field('notes') notes!: string; 23 | @field('avatar') avatar!: string; 24 | @field('phone') phone!: number; 25 | @field('document') document!: string; 26 | @readonly @date('created_at') createdAt!: number; 27 | @readonly @date('updated_at') updatedAt!: number; 28 | 29 | @lazy payments = this.collections 30 | .get('payment_contacts') 31 | .query(Q.where('contact_id', this.id)); 32 | 33 | @writer async delete() { 34 | return await this.markAsDeleted(); 35 | } 36 | 37 | @writer async setUpdate(newData: this) { 38 | return await this.update(record => { 39 | record.name = newData.name; 40 | record.phone = newData.phone; 41 | record.star = newData.star; 42 | record.email = newData.email; 43 | record.notes = newData.notes; 44 | record.avatar = newData.avatar; 45 | record.document = newData.document; 46 | }); 47 | } 48 | 49 | @writer async getContact() { 50 | return { 51 | id: this.id, 52 | name: this.name, 53 | avatar: this.avatar, 54 | phone: this.phone, 55 | email: this.email, 56 | star: this.star, 57 | notes: this.notes, 58 | document: this.document, 59 | }; 60 | } 61 | 62 | @writer async favorite() { 63 | await this.update(record => { 64 | record.star = !record.star; 65 | }); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/database/models/index.ts: -------------------------------------------------------------------------------- 1 | import CatalogModel from "./catalog"; 2 | import ContactModel from "./contact"; 3 | import PaymentModel from "./payment"; 4 | import PaymentCatalogs from "./payment_catalogs"; 5 | import PaymentContacts from "./payment_contacts"; 6 | import TaskModel from "./task"; 7 | 8 | export default [ 9 | ContactModel, 10 | CatalogModel, 11 | PaymentModel, 12 | PaymentCatalogs, 13 | PaymentContacts, 14 | TaskModel, 15 | ]; 16 | -------------------------------------------------------------------------------- /src/database/models/payment.ts: -------------------------------------------------------------------------------- 1 | import { Model, Q } from '@nozbe/watermelondb'; 2 | import { Associations } from '@nozbe/watermelondb/Model'; 3 | import { 4 | field, 5 | date, 6 | readonly, 7 | writer, 8 | lazy, 9 | reader, 10 | } from '@nozbe/watermelondb/decorators'; 11 | 12 | export default class PaymentModel extends Model { 13 | static table = 'payments'; 14 | 15 | static associations: Associations = { 16 | payment_contacts: { type: 'has_many', foreignKey: 'payment_id' }, 17 | payment_catalogs: { type: 'has_many', foreignKey: 'payment_id' }, 18 | }; 19 | 20 | @field('name') name!: string; 21 | @field('star') star!: boolean; 22 | @field('notes') notes!: string; 23 | @field('description') description!: string; 24 | @field('status') status!: IStatus; 25 | @field('extra') extra!: number; 26 | @field('discount') discount!: IDiscount | string; 27 | @field('fee') fee!: IFee | string; 28 | @field('methods') methods!: IMethod[] | string; 29 | @field('date') date!: number; 30 | @readonly @date('created_at') createdAt!: number; 31 | @readonly @date('updated_at') updatedAt!: number; 32 | 33 | @lazy orders = this.collections 34 | .get('payment_catalogs') 35 | .query(Q.on('payments', 'id', this.id)); 36 | 37 | @lazy contacts = this.collections 38 | .get('payment_contacts') 39 | .query(Q.on('payments', 'id', this.id)); 40 | 41 | @writer async delete() { 42 | await this.markAsDeleted(); // syncable 43 | } 44 | 45 | @reader async getPayment() { 46 | return { 47 | id: this.id, 48 | name: this.name, 49 | star: this.star, 50 | notes: this.notes, 51 | description: this.description, 52 | status: this.status, 53 | extra: this.extra, 54 | fee: this.fee, 55 | discount: this.discount, 56 | methods: this.methods, 57 | date: this.date, 58 | }; 59 | } 60 | 61 | @writer async favorite() { 62 | await this.update(record => { 63 | record.star = !record.star; 64 | }); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/database/models/payment_catalogs.ts: -------------------------------------------------------------------------------- 1 | import { Model } from "@nozbe/watermelondb"; 2 | import { 3 | immutableRelation, 4 | relation, 5 | field, 6 | } from "@nozbe/watermelondb/decorators"; 7 | import { Associations } from "@nozbe/watermelondb/Model"; 8 | import CatalogModel from "./catalog"; 9 | import PaymentModel from "./payment"; 10 | 11 | export default class PaymentCatalogs extends Model { 12 | static table = "payment_catalogs"; 13 | 14 | static associations: Associations = { 15 | catalogs: { type: "belongs_to", key: "catalog_id" }, 16 | payments: { type: "belongs_to", key: "payment_id" }, 17 | }; 18 | 19 | @field("amount") amount!: number; 20 | @field("value") value!: number; 21 | @field("cost") cost!: number; 22 | @immutableRelation("catalogs", "catalog_id") catalog!: CatalogModel; 23 | @immutableRelation("payments", "payment_id") payment!: PaymentModel; 24 | } 25 | -------------------------------------------------------------------------------- /src/database/models/payment_contacts.ts: -------------------------------------------------------------------------------- 1 | import { Model } from "@nozbe/watermelondb"; 2 | import { immutableRelation, relation } from "@nozbe/watermelondb/decorators"; 3 | import { Associations } from "@nozbe/watermelondb/Model"; 4 | 5 | export default class PaymentContacts extends Model { 6 | static table = "payment_contacts"; 7 | 8 | static associations: Associations = { 9 | contacts: { type: "belongs_to", key: "contact_id" }, 10 | payments: { type: "belongs_to", key: "payment_id" }, 11 | }; 12 | 13 | @immutableRelation("contacts", "contact_id") contact!: any; 14 | @immutableRelation("payments", "payment_id") payment!: any; 15 | } 16 | -------------------------------------------------------------------------------- /src/database/models/task.ts: -------------------------------------------------------------------------------- 1 | import { Model } from '@nozbe/watermelondb'; 2 | import { Associations } from '@nozbe/watermelondb/Model'; 3 | import { 4 | date, 5 | field, 6 | reader, 7 | readonly, 8 | writer, 9 | } from '@nozbe/watermelondb/decorators'; 10 | 11 | export default class TaskModel extends Model { 12 | static table = 'tasks'; 13 | 14 | static associations: Associations = {}; 15 | 16 | @writer async delete() { 17 | await this.markAsDeleted(); // syncable 18 | } 19 | 20 | @writer async favorite() { 21 | await this.update(record => { 22 | record.star = !record.star; 23 | }); 24 | } 25 | 26 | @reader async getTask() { 27 | const { name, notes, star, date, time, status, type } = this; 28 | 29 | return { 30 | name, 31 | notes, 32 | star, 33 | status, 34 | date, 35 | time, 36 | type, 37 | }; 38 | } 39 | 40 | @writer async setUpdate(newData: this) { 41 | return await this.update(record => { 42 | record.name = newData.name; 43 | record.notes = newData.notes; 44 | record.star = newData.star; 45 | record.status = newData.status; 46 | record.time = newData.time; 47 | record.type = newData.type; 48 | record.date = newData.date; 49 | }); 50 | } 51 | 52 | @writer async setStatus(status: IStatus) { 53 | await this.update(record => { 54 | record.status = status; 55 | }); 56 | } 57 | 58 | @field('name') 59 | name!: string; 60 | 61 | @field('notes') 62 | notes!: string; 63 | 64 | @field('star') 65 | star!: boolean; 66 | 67 | @field('status') 68 | status!: IStatus; 69 | 70 | @field('date') 71 | date!: number; 72 | 73 | @field('time') 74 | time!: number; 75 | 76 | @field('type') 77 | type!: string; 78 | 79 | @readonly 80 | @date('created_at') 81 | createdAt!: number; 82 | 83 | @readonly 84 | @date('updated_at') 85 | updatedAt!: number; 86 | } 87 | -------------------------------------------------------------------------------- /src/database/schema/index.ts: -------------------------------------------------------------------------------- 1 | import { appSchema, tableSchema } from '@nozbe/watermelondb'; 2 | 3 | export default appSchema({ 4 | version: 1, 5 | tables: [ 6 | tableSchema({ 7 | name: 'contacts', 8 | columns: [ 9 | { name: 'name', type: 'string' }, 10 | { name: 'email', type: 'string' }, 11 | { name: 'notes', type: 'string' }, 12 | { name: 'avatar', type: 'string' }, 13 | { name: 'star', type: 'boolean' }, 14 | { name: 'document', type: 'string' }, 15 | { name: 'phone', type: 'number' }, 16 | { name: 'created_at', type: 'number' }, 17 | { name: 'updated_at', type: 'number' }, 18 | ], 19 | }), 20 | tableSchema({ 21 | name: 'tasks', 22 | columns: [ 23 | { name: 'name', type: 'string' }, 24 | { name: 'notes', type: 'string' }, 25 | { name: 'status', type: 'string' }, 26 | { name: 'type', type: 'string' }, 27 | { name: 'time', type: 'number' }, 28 | { name: 'date', type: 'number' }, 29 | { name: 'star', type: 'boolean' }, 30 | { name: 'created_at', type: 'number' }, 31 | { name: 'updated_at', type: 'number' }, 32 | ], 33 | }), 34 | tableSchema({ 35 | name: 'catalogs', 36 | columns: [ 37 | { name: 'name', type: 'string' }, 38 | { name: 'description', type: 'string' }, 39 | { name: 'notes', type: 'string' }, 40 | { name: 'value', type: 'number' }, 41 | { name: 'fill', type: 'string' }, 42 | { name: 'cost', type: 'number' }, 43 | { name: 'code', type: 'string' }, 44 | //{ name: "amount", type: "number" }, 45 | { name: 'category', type: 'string' }, 46 | { name: 'unit', type: 'string' }, 47 | //{ name: "control", type: "boolean" }, 48 | { name: 'star', type: 'boolean' }, 49 | { name: 'created_at', type: 'number' }, 50 | { name: 'updated_at', type: 'number' }, 51 | ], 52 | }), 53 | tableSchema({ 54 | name: 'payments', 55 | columns: [ 56 | { name: 'name', type: 'string' }, 57 | { name: 'description', type: 'string' }, 58 | { name: 'notes', type: 'string' }, 59 | { name: 'extra', type: 'number' }, 60 | { name: 'fee', type: 'string' }, 61 | { name: 'status', type: 'string' }, 62 | { name: 'discount', type: 'string' }, 63 | { name: 'methods', type: 'string' }, 64 | { name: 'star', type: 'boolean' }, 65 | { name: 'date', type: 'number' }, 66 | { name: 'created_at', type: 'number' }, 67 | { name: 'updated_at', type: 'number' }, 68 | ], 69 | }), 70 | tableSchema({ 71 | name: 'payment_contacts', 72 | columns: [ 73 | { name: 'contact_id', type: 'string' }, 74 | { name: 'payment_id', type: 'string' }, 75 | { name: 'created_at', type: 'number' }, 76 | { name: 'updated_at', type: 'number' }, 77 | ], 78 | }), 79 | tableSchema({ 80 | name: 'payment_catalogs', 81 | columns: [ 82 | { name: 'amount', type: 'number' }, 83 | { name: 'value', type: 'number' }, 84 | { name: 'cost', type: 'number' }, 85 | { name: 'catalog_id', type: 'string' }, 86 | { name: 'payment_id', type: 'string' }, 87 | { name: 'created_at', type: 'number' }, 88 | { name: 'updated_at', type: 'number' }, 89 | ], 90 | }), 91 | ], 92 | }); 93 | -------------------------------------------------------------------------------- /src/hooks/useAnimation.ts: -------------------------------------------------------------------------------- 1 | import { useContext } from "react"; 2 | import { LoadingContext } from "../contexts/loading"; 3 | 4 | export default function useAnimation() { 5 | return useContext(LoadingContext); 6 | } 7 | -------------------------------------------------------------------------------- /src/hooks/useAuth.ts: -------------------------------------------------------------------------------- 1 | import { useContext } from "react"; 2 | import { AuthContext } from "../contexts/auth"; 3 | 4 | export default function useAuth() { 5 | return useContext(AuthContext); 6 | } 7 | -------------------------------------------------------------------------------- /src/hooks/useCombinedRefs.ts: -------------------------------------------------------------------------------- 1 | import { useRef, useEffect } from "react"; 2 | 3 | export const useCombinedRefs: any = (...refs: any[]) => { 4 | const targetRef = useRef(); 5 | 6 | useEffect(() => { 7 | refs.forEach((ref) => { 8 | if (!ref) { 9 | return; 10 | } 11 | 12 | if (typeof ref === "function") { 13 | ref(targetRef.current); 14 | } else { 15 | ref.current = targetRef.current; 16 | } 17 | }); 18 | }, [refs]); 19 | 20 | return targetRef; 21 | }; 22 | -------------------------------------------------------------------------------- /src/hooks/useKeyboard.ts: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from 'react'; 2 | import { Keyboard } from 'react-native'; 3 | 4 | export function useKeyboard() { 5 | const [isKeyboardVisible, setKeyboardVisible] = useState(false); 6 | 7 | useEffect(() => { 8 | const keyboardDidShowListener = Keyboard.addListener( 9 | 'keyboardDidShow', 10 | () => { 11 | setKeyboardVisible(true); // or some other action 12 | }, 13 | ); 14 | const keyboardDidHideListener = Keyboard.addListener( 15 | 'keyboardDidHide', 16 | () => { 17 | setKeyboardVisible(false); // or some other action 18 | }, 19 | ); 20 | 21 | return () => { 22 | keyboardDidHideListener.remove(); 23 | keyboardDidShowListener.remove(); 24 | }; 25 | }, []); 26 | 27 | return isKeyboardVisible; 28 | } 29 | -------------------------------------------------------------------------------- /src/hooks/useManager.ts: -------------------------------------------------------------------------------- 1 | import { useContext } from "react"; 2 | import { ManagerContext } from "../contexts/manager"; 3 | 4 | export default function useManager() { 5 | return useContext(ManagerContext); 6 | } 7 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { LogBox } from 'react-native'; 3 | import { GestureHandlerRootView } from 'react-native-gesture-handler'; 4 | 5 | import { AuthProvider } from './contexts/auth'; 6 | import { LoadingProvider } from './contexts/loading'; 7 | 8 | import Routes from './routes'; 9 | 10 | import 'moment/min/locales'; 11 | 12 | export const App: React.FC = () => { 13 | LogBox.ignoreLogs(['VirtualizedLists should never be nested']); 14 | 15 | return ( 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ); 24 | }; 25 | -------------------------------------------------------------------------------- /src/notifications/index.ts: -------------------------------------------------------------------------------- 1 | import PushNotificationIOS from '@react-native-community/push-notification-ios'; 2 | import PushNotification from 'react-native-push-notification'; 3 | 4 | // Must be outside of any component LifeCycle (such as `componentDidMount`). 5 | export const NoficationListener = PushNotification.configure({ 6 | // (optional) Called when Token is generated (iOS and Android) 7 | onRegister: function (token) { 8 | console.log('TOKEN:', token); 9 | }, 10 | 11 | // (required) Called when a remote is received or opened, or local notification is opened 12 | onNotification: function (notification) { 13 | console.log('NOTIFICATION:', notification); 14 | 15 | // process the notification 16 | 17 | // (required) Called when a remote is received or opened, or local notification is opened 18 | notification.finish(PushNotificationIOS.FetchResult.NoData); 19 | }, 20 | 21 | // (optional) Called when Registered Action is pressed and invokeApp is false, if true onNotification will be called (Android) 22 | onAction: function (notification) { 23 | console.log('ACTION:', notification.action); 24 | console.log('NOTIFICATION:', notification); 25 | 26 | // process the action 27 | }, 28 | 29 | // (optional) Called when the user fails to register for remote notifications. Typically occurs when APNS is having issues, or the device is a simulator. (iOS) 30 | onRegistrationError: function (err) { 31 | console.error(err.message, err); 32 | }, 33 | 34 | // IOS ONLY (optional): default: all - Permissions to register. 35 | permissions: { 36 | alert: true, 37 | badge: true, 38 | sound: true, 39 | }, 40 | 41 | // Should the initial notification be popped automatically 42 | // default: true 43 | popInitialNotification: true, 44 | 45 | /** 46 | * (optional) default: true 47 | * - Specified if permissions (ios) and token (android and ios) will requested or not, 48 | * - if not, you must call PushNotificationsHandler.requestPermissions() later 49 | * - if you are not using remote notification or do not have Firebase installed, use this: 50 | * requestPermissions: Platform.OS === 'ios' 51 | */ 52 | requestPermissions: true, 53 | }); 54 | -------------------------------------------------------------------------------- /src/routes/app.routes.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from 'react'; 2 | import PushNotification from 'react-native-push-notification'; 3 | 4 | import { createNativeStackNavigator } from '@react-navigation/native-stack'; 5 | import AsyncStorage from '@react-native-async-storage/async-storage'; 6 | 7 | import { Home } from '../screens/home'; 8 | import { Contacts } from '../screens/contacts'; 9 | import { ContactScreen } from '../screens/contacts/contact'; 10 | import { Catalogs } from '../screens/catalogs'; 11 | import { CatalogScreen } from '../screens/catalogs/catalog'; 12 | import { Payments } from '../screens/payments'; 13 | import { PaymentScreen } from '../screens/payments/payment'; 14 | import { Tasks } from '../screens/tasks'; 15 | import { TaskScreen } from '../screens/tasks/task'; 16 | import { SettingScreen } from '../screens/settings'; 17 | 18 | import { ObservedResumeScreen } from '../screens/resume/observables'; 19 | 20 | import { combinedDate } from '../utils'; 21 | import { TaskNotification } from '../notifications/task'; 22 | import { ManagerProvider } from '../contexts/manager'; 23 | import useAuth from '../hooks/useAuth'; 24 | import DatabaseProvider from '@nozbe/watermelondb/DatabaseProvider'; 25 | import CustomDB from '../database'; 26 | import TaskModel from '../database/models/task'; 27 | 28 | const { Navigator, Screen } = createNativeStackNavigator(); 29 | 30 | export default function AppRoutes() { 31 | const { user, settings } = useAuth(); 32 | const database = CustomDB(user.groups[0].id); 33 | 34 | useEffect(() => { 35 | PushNotification.getScheduledLocalNotifications(async notifications => { 36 | if (notifications.length === 0) { 37 | let tasks = await database.get('tasks').query().fetch(); 38 | 39 | for (let task of tasks) { 40 | let _combinedDate = combinedDate(task.date, task.time); 41 | let now = new Date().getTime(); 42 | let old = new Date(_combinedDate).getTime(); 43 | 44 | if ( 45 | old > now && 46 | task.status === 'pending' && 47 | task.date && 48 | task.time 49 | ) { 50 | TaskNotification( 51 | { title: task.name, ref: task.id }, 52 | { date: new Date(_combinedDate) }, 53 | ); 54 | } 55 | } 56 | } 57 | }); 58 | }, []); 59 | 60 | useEffect(() => { 61 | (async () => { 62 | await AsyncStorage.setItem('@user', JSON.stringify(user)); 63 | })(); 64 | }, [user]); 65 | 66 | useEffect(() => { 67 | (async () => { 68 | await AsyncStorage.setItem('@settings', JSON.stringify(settings)); 69 | })(); 70 | }, [settings]); 71 | 72 | useEffect(() => { 73 | (async () => { 74 | const hasItem = await AsyncStorage.getItem('@database'); 75 | 76 | const myDatabase = { id: user.groups[0].id, date: new Date() }; 77 | 78 | function toSave() { 79 | if (hasItem) { 80 | const data: any[] = JSON.parse(hasItem); 81 | 82 | return data.map(obj => 83 | obj.id === myDatabase.id ? { ...obj, date: myDatabase.date } : obj, 84 | ); 85 | } 86 | 87 | return [myDatabase]; 88 | } 89 | 90 | await AsyncStorage.setItem('@database', JSON.stringify(toSave())); 91 | })(); 92 | }, []); 93 | 94 | return ( 95 | 96 | 97 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | ); 115 | } 116 | -------------------------------------------------------------------------------- /src/routes/auth.routes.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import { createNativeStackNavigator } from '@react-navigation/native-stack'; 4 | 5 | import Welcome from '../screens/auth/welcome'; 6 | import Login from '../screens/auth/login'; 7 | import Register from '../screens/auth/register'; 8 | 9 | const { Navigator, Screen } = createNativeStackNavigator(); 10 | 11 | export default function AuthRoutes() { 12 | return ( 13 | 16 | 17 | 18 | 19 | 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /src/routes/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | 3 | import * as Keychain from 'react-native-keychain'; 4 | import AsyncStorage from '@react-native-async-storage/async-storage'; 5 | import RNBootSplash from 'react-native-bootsplash'; 6 | 7 | import { StatusBar } from 'react-native'; 8 | import { NavigationContainer } from '@react-navigation/native'; 9 | import { AxiosResponse } from 'axios'; 10 | 11 | import { api } from '../services/api'; 12 | 13 | import useAuth from '../hooks/useAuth'; 14 | import AppRoutes from './app.routes'; 15 | import AuthRoutes from './auth.routes'; 16 | import Loading from '../components/Loading'; 17 | import { API_URL } from '@env'; 18 | 19 | export default function Routes() { 20 | const [isLoadingComplete, setLoadingComplete] = useState(false); 21 | 22 | const { user, setUser, setSettings, signOut } = useAuth(); 23 | 24 | useEffect(() => { 25 | (async () => { 26 | const credentials = await Keychain.getGenericPassword(); 27 | const data = await AsyncStorage.getItem('@user'); 28 | const settings = await AsyncStorage.getItem('@settings'); 29 | 30 | function setCachedData() { 31 | if (data && !isLoadingComplete) { 32 | setUser(JSON.parse(data)); 33 | } 34 | } 35 | 36 | if (settings && !isLoadingComplete) { 37 | setSettings(JSON.parse(settings)); 38 | } 39 | 40 | if (credentials) { 41 | try { 42 | const response: AxiosResponse = await api.post( 43 | '/auth/login', 44 | { 45 | email: credentials.username.trim(), 46 | password: credentials.password, 47 | }, 48 | ); 49 | 50 | if (response.status === 403) { 51 | return await signOut(); 52 | } 53 | 54 | api.defaults.headers.common.Authorization = `Bearer ${response.data.token}`; 55 | setUser(response.data.user); 56 | } catch (e) { 57 | setCachedData(); 58 | } 59 | } 60 | 61 | if (!isLoadingComplete) { 62 | console.log(API_URL); 63 | setLoadingComplete(true); 64 | await RNBootSplash.hide(); 65 | } 66 | })(); 67 | }, []); 68 | 69 | return ( 70 | 71 | 76 | {!isLoadingComplete ? ( 77 | 78 | ) : user.id ? ( 79 | 80 | ) : ( 81 | 82 | )} 83 | 84 | ); 85 | } 86 | -------------------------------------------------------------------------------- /src/screens/auth/welcome/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; 3 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 4 | import { Fonts } from '../../../constants/fonts'; 5 | import { useNavigation } from '@react-navigation/core'; 6 | import { ScreenHeight } from '../../../utils/layout'; 7 | import { Colors } from '../../../constants/colors'; 8 | import WelcomeBrand from '../../../assets/svg/welcome.svg'; 9 | 10 | const Welcome: React.FC = () => { 11 | const Navigation = useNavigation(); 12 | 13 | function _toLogin() { 14 | Navigation.navigate('login' as never); 15 | } 16 | 17 | return ( 18 | 19 | 20 | 21 | 22 | Bem vindo ao Mundo dos Negócios, 23 | 24 | 25 | Organize a sua empresa e comece na frente! 26 | 27 | 28 | 29 | 34 | 35 | 36 | ); 37 | }; 38 | 39 | const styles = StyleSheet.create({ 40 | container: { 41 | flex: 1, 42 | backgroundColor: 'white', 43 | justifyContent: 'center', 44 | alignItems: 'center', 45 | }, 46 | greeting: { 47 | marginVertical: 15, 48 | alignItems: 'center', 49 | }, 50 | greetingText: { 51 | color: 'grey', 52 | fontSize: 13, 53 | fontFamily: Fonts.text, 54 | }, 55 | }); 56 | 57 | export default Welcome; 58 | -------------------------------------------------------------------------------- /src/screens/catalogs/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useNavigation } from '@react-navigation/native'; 3 | import { Constants } from '../../constants'; 4 | import { BackButton } from '../../components/BackButton'; 5 | import { SearchBar } from '../../components/Search'; 6 | import { CustomButton } from '../../components/CustomButton'; 7 | import { StyleSheet, Text, View } from 'react-native'; 8 | import { Colors } from '../../constants/colors'; 9 | import { Fonts } from '../../constants/fonts'; 10 | import { AnimatedHeaderComponent, AnimatedIcon } from '../../utils/container'; 11 | import { ObservedCatalogs } from '../../components/Cards/Catalog/observables'; 12 | import { 13 | Extrapolate, 14 | interpolate, 15 | useAnimatedScrollHandler, 16 | useAnimatedStyle, 17 | useSharedValue, 18 | } from 'react-native-reanimated'; 19 | 20 | export function Catalogs() { 21 | const navigation = useNavigation(); 22 | const [filter, setFilter] = useState(''); 23 | 24 | const scrollY = useSharedValue(0); 25 | 26 | const scrollHandler = useAnimatedScrollHandler((event: any) => { 27 | scrollY.value = event.contentOffset.y; 28 | }); 29 | 30 | const headerStyle = useAnimatedStyle(() => { 31 | return { 32 | height: interpolate( 33 | scrollY.value, 34 | [0, Constants.HEADER_MAX_HEIGHT], 35 | [Constants.HEADER_MAX_HEIGHT, Constants.HEADER_MIN_HEIGHT], 36 | Extrapolate.CLAMP, 37 | ), 38 | }; 39 | }); 40 | 41 | const avatarStyle = useAnimatedStyle(() => { 42 | return { 43 | opacity: interpolate( 44 | scrollY.value, 45 | [40, Constants.HEADER_MAX_HEIGHT], 46 | [1, 0], 47 | Extrapolate.CLAMP, 48 | ), 49 | }; 50 | }); 51 | 52 | return ( 53 | 54 | 59 | 60 | 61 | 62 | navigation.navigate('catalog' as never, {} as never)} 66 | /> 67 | 68 | 69 | 75 | 76 | 77 | Catálogos 78 | 79 | 80 | 86 | 87 | ); 88 | } 89 | 90 | const styles = StyleSheet.create({ 91 | container: { 92 | flex: 1, 93 | backgroundColor: 'white', 94 | }, 95 | header: { 96 | position: 'absolute', 97 | paddingTop: Constants.STATUS_BAR_HEIGHT, 98 | top: 0, 99 | left: 0, 100 | right: 0, 101 | zIndex: 999, 102 | }, 103 | navigation: { 104 | width: '100%', 105 | flexDirection: 'row', 106 | justifyContent: 'space-between', 107 | alignItems: 'center', 108 | paddingTop: 15, 109 | paddingHorizontal: 15, 110 | }, 111 | icontainer: { 112 | flex: 1, 113 | alignItems: 'center', 114 | justifyContent: 'center', 115 | }, 116 | listHeader: { 117 | position: 'relative', 118 | height: 55, 119 | borderBottomWidth: 1, 120 | alignItems: 'center', 121 | justifyContent: 'center', 122 | borderColor: '#eee', 123 | backgroundColor: '#fff', 124 | }, 125 | listTitle: { 126 | color: Colors.heading, 127 | fontFamily: Fonts.heading, 128 | fontSize: 16, 129 | }, 130 | }); 131 | -------------------------------------------------------------------------------- /src/screens/contacts/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useNavigation } from '@react-navigation/native'; 3 | import { Constants } from '../../constants'; 4 | import { BackButton } from '../../components/BackButton'; 5 | import { SearchBar } from '../../components/Search'; 6 | import { CustomButton } from '../../components/CustomButton'; 7 | import { StyleSheet, Text, View } from 'react-native'; 8 | import { Colors } from '../../constants/colors'; 9 | import { Fonts } from '../../constants/fonts'; 10 | import { AnimatedHeaderComponent, AnimatedIcon } from '../../utils/container'; 11 | import { 12 | Extrapolate, 13 | interpolate, 14 | useAnimatedScrollHandler, 15 | useAnimatedStyle, 16 | useSharedValue, 17 | } from 'react-native-reanimated'; 18 | 19 | import { ObservedContacts } from '../../components/Cards/Contact/observables'; 20 | 21 | export function Contacts() { 22 | const navigation = useNavigation(); 23 | const scrollY = useSharedValue(0); 24 | 25 | const [filter, setFilter] = useState(''); 26 | 27 | const scrollHandler = useAnimatedScrollHandler((event: any) => { 28 | scrollY.value = event.contentOffset.y; 29 | }); 30 | 31 | const headerStyle = useAnimatedStyle(() => { 32 | return { 33 | height: interpolate( 34 | scrollY.value, 35 | [0, Constants.HEADER_MAX_HEIGHT], 36 | [Constants.HEADER_MAX_HEIGHT, Constants.HEADER_MIN_HEIGHT], 37 | Extrapolate.CLAMP, 38 | ), 39 | }; 40 | }); 41 | 42 | const avatarStyle = useAnimatedStyle(() => { 43 | return { 44 | opacity: interpolate( 45 | scrollY.value, 46 | [40, Constants.HEADER_MAX_HEIGHT], 47 | [1, 0], 48 | Extrapolate.CLAMP, 49 | ), 50 | }; 51 | }); 52 | 53 | return ( 54 | 55 | 60 | 61 | 62 | 63 | { 67 | navigation.navigate('contact' as never, {} as never); 68 | }} 69 | /> 70 | 71 | 72 | 78 | 79 | 80 | Contatos 81 | 82 | 83 | 89 | 90 | ); 91 | } 92 | 93 | const styles = StyleSheet.create({ 94 | container: { 95 | flex: 1, 96 | backgroundColor: 'white', 97 | }, 98 | header: { 99 | position: 'absolute', 100 | paddingTop: Constants.STATUS_BAR_HEIGHT, 101 | top: 0, 102 | left: 0, 103 | right: 0, 104 | zIndex: 7, 105 | }, 106 | navigation: { 107 | width: '100%', 108 | flexDirection: 'row', 109 | justifyContent: 'space-between', 110 | alignItems: 'center', 111 | paddingTop: 15, 112 | paddingHorizontal: 15, 113 | }, 114 | icontainer: { 115 | flex: 1, 116 | alignItems: 'center', 117 | justifyContent: 'center', 118 | }, 119 | listHeader: { 120 | position: 'relative', 121 | height: 55, 122 | borderBottomWidth: 1, 123 | alignItems: 'center', 124 | justifyContent: 'center', 125 | borderColor: '#eee', 126 | backgroundColor: '#fff', 127 | }, 128 | listTitle: { 129 | color: Colors.heading, 130 | fontFamily: Fonts.heading, 131 | fontSize: 16, 132 | }, 133 | }); 134 | -------------------------------------------------------------------------------- /src/screens/home/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useMemo, useState } from 'react'; 2 | import { FlatList, StyleSheet, Text, View } from 'react-native'; 3 | import { useNavigation } from '@react-navigation/native'; 4 | 5 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 6 | 7 | import { Constants } from '../../constants'; 8 | import { Colors } from '../../constants/colors'; 9 | import { Activities } from '../../components/Activities'; 10 | import { Fonts } from '../../constants/fonts'; 11 | import { Shortcuts } from '../../components/Shortcuts'; 12 | import { CustomButton } from '../../components/CustomButton'; 13 | import { DailyTasks } from './tasks'; 14 | import useAuth from '../../hooks/useAuth'; 15 | 16 | export function Home() { 17 | const navigation = useNavigation(); 18 | const { signOut } = useAuth(); 19 | 20 | const [currentMillis, setCurrentMillis] = useState(new Date()); 21 | 22 | useEffect(() => { 23 | const changeDay = setInterval(() => { 24 | if (new Date().getDay() !== currentMillis.getDay()) { 25 | setCurrentMillis(new Date()); 26 | } 27 | }, 30 * 1000); 28 | 29 | return () => { 30 | clearInterval(changeDay); 31 | }; 32 | }, [currentMillis]); 33 | 34 | const { deck, indices } = useMemo(() => { 35 | const indices: number[] = []; 36 | const items: IDeck[] = [ 37 | { 38 | key: 'HEADER', 39 | render: () => ( 40 | 41 | 42 | 47 | MEI Spot 48 | 49 | 55 | 56 | ), 57 | }, 58 | { 59 | key: 'SHORTCUTS', 60 | render: () => , 61 | }, 62 | { 63 | key: 'ACTIVITIES', 64 | render: () => , 65 | }, 66 | { 67 | key: 'FAVORITES', 68 | render: () => Tarefas do dia, 69 | }, 70 | { 71 | key: 'daily-tasks', 72 | render: () => ( 73 | 79 | ), 80 | }, 81 | ]; 82 | 83 | items.forEach((item, index) => item.isTitle && indices.push(index)); 84 | 85 | return { 86 | deck: items, 87 | indices, 88 | }; 89 | }, [navigation, currentMillis]); 90 | 91 | return ( 92 | 93 | 94 | data={deck} 95 | nestedScrollEnabled 96 | showsVerticalScrollIndicator={false} 97 | stickyHeaderIndices={indices} 98 | keyExtractor={item => item.key} 99 | renderItem={({ item }) => item.render()} 100 | /> 101 | 102 | ); 103 | } 104 | 105 | const styles = StyleSheet.create({ 106 | container: { 107 | flex: 1, 108 | paddingTop: Constants.STATUS_BAR_HEIGHT, 109 | backgroundColor: 'white', 110 | }, 111 | header: { 112 | flexDirection: 'row', 113 | alignItems: 'center', 114 | justifyContent: 'space-between', 115 | padding: 15, 116 | }, 117 | headerLeft: { 118 | flexDirection: 'row', 119 | alignItems: 'center', 120 | }, 121 | headerTitle: { 122 | fontFamily: Fonts.heading, 123 | fontSize: 18, 124 | color: Colors.green, 125 | marginHorizontal: 10, 126 | }, 127 | title: { 128 | color: Colors.green, 129 | fontSize: 16, 130 | fontFamily: Fonts.heading, 131 | textTransform: 'uppercase', 132 | padding: 15, 133 | backgroundColor: 'white', 134 | }, 135 | }); 136 | -------------------------------------------------------------------------------- /src/screens/home/tasks.ts: -------------------------------------------------------------------------------- 1 | import withObservables from '@nozbe/with-observables'; 2 | import { Database, Q } from '@nozbe/watermelondb'; 3 | import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'; 4 | import { ObservedList } from '../../components/Cards'; 5 | 6 | interface IObservables { 7 | database: Database; 8 | startDay: number; 9 | endDay: number; 10 | } 11 | 12 | const enhance = withObservables( 13 | ['database', 'startDay', 'endDay'], 14 | ({ database, startDay, endDay }: IObservables) => ({ 15 | items: database.collections 16 | .get('tasks') 17 | .query( 18 | Q.sortBy('star', Q.desc), 19 | Q.sortBy('date', Q.desc), 20 | Q.where('date', Q.between(startDay, endDay)), 21 | Q.where('status', Q.like('pending')), 22 | ), 23 | }), 24 | ); 25 | 26 | export const DailyTasks = withDatabase(enhance(ObservedList)); 27 | -------------------------------------------------------------------------------- /src/screens/payments/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { StyleSheet, Text, View } from 'react-native'; 3 | import { useNavigation } from '@react-navigation/native'; 4 | import { Constants } from '../../constants'; 5 | import { BackButton } from '../../components/BackButton'; 6 | import { SearchBar } from '../../components/Search'; 7 | import { CustomButton } from '../../components/CustomButton'; 8 | import { Colors } from '../../constants/colors'; 9 | import { Fonts } from '../../constants/fonts'; 10 | import { AnimatedHeaderComponent, AnimatedIcon } from '../../utils/container'; 11 | import { FABSelect } from '../../components/Select/Button'; 12 | import { LabelOptions } from '../../components/Select/Components/Label'; 13 | import { ObservedPayments } from '../../components/Cards/Payment/observables'; 14 | import { 15 | Extrapolate, 16 | interpolate, 17 | useAnimatedScrollHandler, 18 | useAnimatedStyle, 19 | useSharedValue, 20 | } from 'react-native-reanimated'; 21 | 22 | import Status from '../../@maps/Status'; 23 | 24 | export function Payments() { 25 | const navigation = useNavigation(); 26 | const [status, setStatus] = useState(''); 27 | const [filter, setFilter] = useState(''); 28 | 29 | const scrollY = useSharedValue(0); 30 | 31 | const scrollHandler = useAnimatedScrollHandler((event: any) => { 32 | scrollY.value = event.contentOffset.y; 33 | }); 34 | 35 | const headerStyle = useAnimatedStyle(() => { 36 | return { 37 | height: interpolate( 38 | scrollY.value, 39 | [0, Constants.HEADER_MAX_HEIGHT], 40 | [Constants.HEADER_MAX_HEIGHT, Constants.HEADER_MIN_HEIGHT], 41 | Extrapolate.CLAMP, 42 | ), 43 | }; 44 | }); 45 | 46 | const avatarStyle = useAnimatedStyle(() => { 47 | return { 48 | opacity: interpolate( 49 | scrollY.value, 50 | [40, Constants.HEADER_MAX_HEIGHT], 51 | [1, 0], 52 | Extrapolate.CLAMP, 53 | ), 54 | }; 55 | }); 56 | 57 | return ( 58 | 59 | 64 | 65 | 66 | 67 | navigation.navigate('payment' as never, {} as never)} 71 | /> 72 | 73 | 74 | 80 | 81 | 82 | {Status(status).payments} 83 | 84 | 85 | 94 | 107 | 108 | ); 109 | } 110 | 111 | const styles = StyleSheet.create({ 112 | container: { 113 | flex: 1, 114 | backgroundColor: 'white', 115 | }, 116 | header: { 117 | position: 'absolute', 118 | paddingTop: Constants.STATUS_BAR_HEIGHT, 119 | top: 0, 120 | left: 0, 121 | right: 0, 122 | zIndex: 999, 123 | }, 124 | navigation: { 125 | width: '100%', 126 | flexDirection: 'row', 127 | justifyContent: 'space-between', 128 | alignItems: 'center', 129 | paddingTop: 15, 130 | paddingHorizontal: 15, 131 | }, 132 | icontainer: { 133 | flex: 1, 134 | alignItems: 'center', 135 | justifyContent: 'center', 136 | }, 137 | listHeader: { 138 | position: 'relative', 139 | height: 55, 140 | borderBottomWidth: 1, 141 | alignItems: 'center', 142 | justifyContent: 'center', 143 | borderColor: '#eee', 144 | backgroundColor: '#fff', 145 | }, 146 | listTitle: { 147 | color: Colors.heading, 148 | fontFamily: Fonts.heading, 149 | fontSize: 16, 150 | }, 151 | }); 152 | -------------------------------------------------------------------------------- /src/screens/payments/payment/contacts/contact/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { 3 | Alert, 4 | StyleSheet, 5 | Text, 6 | TouchableOpacity, 7 | ViewProps, 8 | } from 'react-native'; 9 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 10 | import { Colors } from '../../../../../constants/colors'; 11 | import { Constants } from '../../../../../constants'; 12 | import { Fonts } from '../../../../../constants/fonts'; 13 | import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'; 14 | import useManager from '../../../../../hooks/useManager'; 15 | import withObservables from '@nozbe/with-observables'; 16 | import ContactModel from '../../../../../database/models/contact'; 17 | 18 | interface IProps extends ViewProps { 19 | data: IContactProps; 20 | contact: ContactModel; 21 | } 22 | 23 | export const Contact: React.FC = ({ data, contact }) => { 24 | const { contacts } = useManager(); 25 | 26 | function _remove() { 27 | Alert.alert( 28 | contact.name, 29 | 'Deseja remover este contato?', 30 | [ 31 | { 32 | text: 'Não', 33 | onPress: () => console.log('No, continue editing'), 34 | }, 35 | { 36 | style: 'cancel', 37 | text: 'Sim', 38 | onPress: () => contacts.remove(data.contact_id), 39 | }, 40 | ], 41 | { cancelable: false }, 42 | ); 43 | } 44 | 45 | return ( 46 | 47 | 53 | 54 | {contact.name} 55 | 56 | 57 | ); 58 | }; 59 | 60 | export const ObservedContact = withDatabase( 61 | withObservables(['database', 'data'], ({ database, data }) => ({ 62 | contact: database.get('contacts').findAndObserve(data.contact_id), 63 | }))(Contact), 64 | ); 65 | 66 | const styles = StyleSheet.create({ 67 | iconContainer: { 68 | backgroundColor: Colors.green, 69 | padding: Constants.CARD_ICON_SIZE / 4, 70 | borderRadius: Constants.CARD_ICON_SIZE, 71 | }, 72 | label: { 73 | fontFamily: Fonts.text, 74 | fontSize: 9, 75 | color: Colors.heading, 76 | marginTop: 2.4, 77 | maxWidth: 40, 78 | }, 79 | }); 80 | -------------------------------------------------------------------------------- /src/screens/payments/payment/contacts/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ScrollView, View } from 'react-native'; 3 | import { ObservedContact } from './contact'; 4 | import { Empty } from '../../../../components/Empty'; 5 | 6 | interface IProps { 7 | data: IContactProps[]; 8 | } 9 | 10 | export function Contacts({ data }: IProps) { 11 | let _data = data.filter(e => e.status !== 'deleted'); 12 | 13 | if (!_data.length) return ; 14 | 15 | return ( 16 | 20 | {_data.map((e, i) => { 21 | let divider = _data.length - 1 === i ? 15 : 10; 22 | 23 | return ( 24 | 25 | 26 | 27 | ); 28 | })} 29 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /src/screens/payments/payment/events/load/contacts.ts: -------------------------------------------------------------------------------- 1 | import { Q, Database } from "@nozbe/watermelondb"; 2 | import PaymentContacts from "../../../../../database/models/payment_contacts"; 3 | 4 | interface IProps { 5 | id: any; 6 | database: Database; 7 | } 8 | 9 | export async function getContacts({ database, id }: IProps) { 10 | let _contacts: IContactProps[] = []; 11 | 12 | let relation = await database 13 | .get("payment_contacts") 14 | .query(Q.where("payment_id", id)) 15 | .fetch(); 16 | 17 | for (let _relation of relation) { 18 | _contacts.push({ 19 | status: "created", 20 | contact_id: _relation.contact.id, 21 | relation_id: _relation.id, 22 | }); 23 | } 24 | 25 | return _contacts; 26 | } 27 | -------------------------------------------------------------------------------- /src/screens/payments/payment/events/load/orders.ts: -------------------------------------------------------------------------------- 1 | import { Q, Database } from "@nozbe/watermelondb"; 2 | import PaymentCatalogs from "../../../../../database/models/payment_catalogs"; 3 | 4 | interface IProps { 5 | id: any; 6 | database: Database; 7 | } 8 | 9 | export async function getOrders({ database, id }: IProps) { 10 | let _orders: IStockProps[] = []; 11 | 12 | let relation = await database 13 | .get("payment_catalogs") 14 | .query(Q.where("payment_id", id)) 15 | .fetch(); 16 | 17 | for (let _relation of relation) { 18 | _orders.push({ 19 | status: "created", 20 | cost: _relation.cost, 21 | value: _relation.value, 22 | amount: _relation.amount, 23 | catalog_id: _relation.catalog.id, 24 | relation_id: _relation.id, 25 | }); 26 | } 27 | 28 | return _orders; 29 | } 30 | -------------------------------------------------------------------------------- /src/screens/payments/payment/events/save/contacts.ts: -------------------------------------------------------------------------------- 1 | import { Database } from "@nozbe/watermelondb"; 2 | import PaymentContacts from "../../../../../database/models/payment_contacts"; 3 | 4 | interface IProps { 5 | id: any; 6 | contacts: { data: IContactProps[] }; 7 | database: Database; 8 | } 9 | 10 | export async function setContacts({ id, contacts, database }: IProps) { 11 | let actions: PaymentContacts[] = []; 12 | 13 | for (let item of contacts.data) { 14 | const get = database.get("payment_contacts"); 15 | 16 | if (item.relation_id) { 17 | const result = await get.find(item.relation_id); 18 | 19 | if (item.status === "deleted") { 20 | actions.push(result.prepareMarkAsDeleted()); 21 | } else { 22 | actions.push(result.prepareUpdate((record) => {})); 23 | } 24 | } else { 25 | actions.push( 26 | get.prepareCreate((record) => { 27 | record.contact.id = item.contact_id; 28 | record.payment.id = id; 29 | }) 30 | ); 31 | } 32 | } 33 | 34 | return actions; 35 | } 36 | -------------------------------------------------------------------------------- /src/screens/payments/payment/events/save/orders.ts: -------------------------------------------------------------------------------- 1 | import { Database } from "@nozbe/watermelondb"; 2 | import PaymentCatalogs from "../../../../../database/models/payment_catalogs"; 3 | 4 | interface IProps { 5 | id: any; 6 | orders: { data: IStockProps[] }; 7 | database: Database; 8 | } 9 | 10 | export async function setOrders({ id, orders, database }: IProps) { 11 | let actions: PaymentCatalogs[] = []; 12 | 13 | for (let order of orders.data) { 14 | const get = database.get("payment_catalogs"); 15 | 16 | if (order.relation_id) { 17 | const result = await get.find(order.relation_id); 18 | 19 | if (order.status === "deleted") { 20 | actions.push(result.prepareMarkAsDeleted()); 21 | } else { 22 | actions.push( 23 | result.prepareUpdate((record) => { 24 | record.amount = order.amount; 25 | record.value = order.value; 26 | record.cost = order.cost; 27 | }) 28 | ); 29 | } 30 | } else { 31 | actions.push( 32 | get.prepareCreate((record) => { 33 | record.amount = order.amount; 34 | record.value = order.value; 35 | record.cost = order.cost; 36 | record.catalog.id = order.catalog_id; 37 | record.payment.id = id; 38 | }) 39 | ); 40 | } 41 | } 42 | 43 | return actions; 44 | } 45 | -------------------------------------------------------------------------------- /src/screens/payments/payment/orders/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View } from 'react-native'; 3 | import { Empty } from '../../../../components/Empty'; 4 | import { ObservedOrder } from './order'; 5 | 6 | interface IProps { 7 | data: IStockProps[]; 8 | } 9 | 10 | export function Orders({ data }: IProps) { 11 | let _data = data.filter(e => e.status !== 'deleted'); 12 | 13 | if (!_data.length) return ; 14 | 15 | return ( 16 | <> 17 | {_data.map((e, i) => { 18 | let divider = _data.length > 1 && i !== _data.length - 1 ? 15 : 0; 19 | 20 | return ( 21 | 22 | 23 | 24 | ); 25 | })} 26 | 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /src/screens/resume/observables.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import withObservables from '@nozbe/with-observables'; 3 | import { Database, Q } from '@nozbe/watermelondb'; 4 | import { ResumeScreen } from '.'; 5 | import { betweenDays } from '../../utils'; 6 | import { useDatabase } from '@nozbe/watermelondb/hooks'; 7 | import useManager from '../../hooks/useManager'; 8 | 9 | interface IObservables { 10 | start: number; 11 | end: number; 12 | database: Database; 13 | } 14 | 15 | const EnhancedScreen = withObservables( 16 | ['database', 'start', 'end'], 17 | ({ database, start, end }: IObservables) => ({ 18 | contacts: database.collections 19 | .get('contacts') 20 | .query( 21 | Q.sortBy('star', Q.desc), 22 | Q.where('created_at', Q.between(start, end)), 23 | ), 24 | tasks: database.collections 25 | .get('tasks') 26 | .query( 27 | Q.sortBy('star', Q.desc), 28 | Q.or( 29 | Q.where('date', Q.between(start, end)), 30 | Q.where('created_at', Q.between(start, end)), 31 | ), 32 | ), 33 | payments: database.collections 34 | .get('payments') 35 | .query(Q.sortBy('star', Q.desc), Q.where('date', Q.between(start, end))), 36 | }), 37 | )(ResumeScreen); 38 | 39 | export const ObservedResumeScreen: React.FC = () => { 40 | const database = useDatabase(); 41 | const { search } = useManager(); 42 | 43 | const filter = () => { 44 | switch (search.type) { 45 | case 'month': 46 | return betweenDays(30); 47 | default: 48 | return search; 49 | } 50 | }; 51 | 52 | return ( 53 | 59 | ); 60 | }; 61 | -------------------------------------------------------------------------------- /src/screens/settings/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Alert, StyleSheet, Text, View } from 'react-native'; 3 | 4 | import LanguageContent, { Languages } from '../../@maps/Language'; 5 | import { CurrencyList } from '../../@maps/Currency'; 6 | import { Constants } from '../../constants'; 7 | import { Fonts } from '../../constants/fonts'; 8 | import { Colors } from '../../constants/colors'; 9 | import { InputSelect } from '../../components/Select/Input'; 10 | import { LabelOptions } from '../../components/Select/Components/Label'; 11 | import { CustomButton } from '../../components/CustomButton'; 12 | import { KeyboardAvoidingWrapper } from '../../components/KeyboardAvoidingWrapper'; 13 | import { Header } from '../../components/Header'; 14 | import { AnimatedIcon } from '../../utils/container'; 15 | 16 | import GroupInput from '../../components/Input'; 17 | import useAuth from '../../hooks/useAuth'; 18 | 19 | export function SettingScreen() { 20 | const { user, settings, setSettings } = useAuth(); 21 | 22 | function help() { 23 | return Alert.alert( 24 | '', 25 | 'Encontre informações sobre a sua conta e configurações do aplicativo.', 26 | ); 27 | } 28 | 29 | return ( 30 | 31 |

32 | 33 | 34 | 39 | 40 | 41 | } 46 | /> 47 | } 52 | /> 53 | 54 | 55 | 56 | Idioma 57 | setSettings({ ...settings, language })} 62 | OptionComponent={LabelOptions} 63 | /> 64 | 65 | 66 | 67 | Moeda 68 | setSettings({ ...settings, currency })} 73 | OptionComponent={LabelOptions} 74 | /> 75 | 76 | 77 | 78 | ); 79 | } 80 | 81 | const styles = StyleSheet.create({ 82 | input: { 83 | backgroundColor: 'white', 84 | paddingHorizontal: 15, 85 | fontSize: 14, 86 | }, 87 | title: { 88 | fontSize: 16, 89 | fontFamily: Fonts.heading, 90 | color: Colors.heading, 91 | }, 92 | category: { 93 | marginHorizontal: 15, 94 | flexDirection: 'row', 95 | alignItems: 'center', 96 | justifyContent: 'space-between', 97 | }, 98 | divider: { 99 | width: '100%', 100 | height: 15, 101 | }, 102 | iconBackground: { 103 | alignItems: 'center', 104 | justifyContent: 'center', 105 | height: 160, 106 | backgroundColor: '#f9f9fa', 107 | borderBottomWidth: 1, 108 | borderColor: '#eee', 109 | }, 110 | }); 111 | -------------------------------------------------------------------------------- /src/screens/tasks/index.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from 'react'; 2 | import { useNavigation } from '@react-navigation/native'; 3 | import { Constants } from '../../constants'; 4 | import { BackButton } from '../../components/BackButton'; 5 | import { SearchBar } from '../../components/Search'; 6 | import { CustomButton } from '../../components/CustomButton'; 7 | import { StyleSheet, Text, View } from 'react-native'; 8 | import { Colors } from '../../constants/colors'; 9 | import { Fonts } from '../../constants/fonts'; 10 | import { AnimatedHeaderComponent, AnimatedIcon } from '../../utils/container'; 11 | import { 12 | Extrapolate, 13 | interpolate, 14 | useAnimatedScrollHandler, 15 | useAnimatedStyle, 16 | useSharedValue, 17 | } from 'react-native-reanimated'; 18 | 19 | import { ObservedTasks } from '../../components/Cards/Task/observables'; 20 | 21 | export function Tasks() { 22 | //const isKeyboard = useKeyboard(); 23 | const navigation = useNavigation(); 24 | const scrollY = useSharedValue(0); 25 | 26 | const [filter, setFilter] = useState(''); 27 | // const [loading, setLoading] = useState(true); 28 | 29 | const scrollHandler = useAnimatedScrollHandler((event: any) => { 30 | scrollY.value = event.contentOffset.y; 31 | }); 32 | 33 | const headerStyle = useAnimatedStyle(() => { 34 | return { 35 | height: interpolate( 36 | scrollY.value, 37 | [0, Constants.HEADER_MAX_HEIGHT], 38 | [Constants.HEADER_MAX_HEIGHT, Constants.HEADER_MIN_HEIGHT], 39 | Extrapolate.CLAMP, 40 | ), 41 | }; 42 | }); 43 | 44 | const avatarStyle = useAnimatedStyle(() => { 45 | return { 46 | opacity: interpolate( 47 | scrollY.value, 48 | [40, Constants.HEADER_MAX_HEIGHT], 49 | [1, 0], 50 | Extrapolate.CLAMP, 51 | ), 52 | }; 53 | }); 54 | 55 | return ( 56 | 57 | 62 | 63 | 64 | 65 | { 69 | navigation.navigate('task' as never, {} as never); 70 | }} 71 | /> 72 | 73 | 74 | 80 | 81 | 82 | Tarefas 83 | 84 | 85 | 91 | 92 | ); 93 | } 94 | 95 | const styles = StyleSheet.create({ 96 | container: { 97 | flex: 1, 98 | backgroundColor: 'white', 99 | }, 100 | header: { 101 | position: 'absolute', 102 | paddingTop: Constants.STATUS_BAR_HEIGHT, 103 | top: 0, 104 | left: 0, 105 | right: 0, 106 | zIndex: 7, 107 | }, 108 | navigation: { 109 | width: '100%', 110 | flexDirection: 'row', 111 | justifyContent: 'space-between', 112 | alignItems: 'center', 113 | paddingTop: 15, 114 | paddingHorizontal: 15, 115 | }, 116 | icontainer: { 117 | flex: 1, 118 | alignItems: 'center', 119 | justifyContent: 'center', 120 | }, 121 | listHeader: { 122 | position: 'relative', 123 | height: 55, 124 | borderBottomWidth: 1, 125 | alignItems: 'center', 126 | justifyContent: 'center', 127 | borderColor: '#eee', 128 | backgroundColor: '#fff', 129 | }, 130 | listTitle: { 131 | color: Colors.heading, 132 | fontFamily: Fonts.heading, 133 | fontSize: 16, 134 | }, 135 | }); 136 | -------------------------------------------------------------------------------- /src/services/api.ts: -------------------------------------------------------------------------------- 1 | import { API_URL } from '@env'; 2 | import axios from 'axios'; 3 | 4 | export const api = axios.create({ 5 | baseURL: API_URL, 6 | headers: { 7 | 'Content-Type': 'application/json', 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /src/skeletons/card.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | import { Constants } from '../constants'; 4 | import { ShimmerPlaceholder } from '../utils/container'; 5 | import { ScreenWidth } from '../utils/layout'; 6 | 7 | export const SkeletonCard: React.FC = () => { 8 | return ( 9 | 10 | 11 | 12 | 13 | 16 | 19 | 20 | 21 | 22 | 23 | ); 24 | }; 25 | 26 | const styles = StyleSheet.create({ 27 | container: { 28 | height: Constants.CARD_ITEM_HEIGHT, 29 | paddingHorizontal: 15, 30 | flexDirection: 'row', 31 | alignItems: 'center', 32 | justifyContent: 'space-between', 33 | }, 34 | left: { 35 | flexDirection: 'row', 36 | alignItems: 'center', 37 | }, 38 | icon: { 39 | width: Constants.CARD_ICON_SIZE, 40 | height: Constants.CARD_ICON_SIZE, 41 | borderRadius: 999, 42 | }, 43 | text: { 44 | marginVertical: 2.4, 45 | borderRadius: 999, 46 | }, 47 | }); 48 | -------------------------------------------------------------------------------- /src/skeletons/home.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { StyleSheet, View } from 'react-native'; 3 | import { Constants } from '../constants'; 4 | import { ShimmerPlaceholder } from '../utils/container'; 5 | import { ScreenWidth } from '../utils/layout'; 6 | import { SkeletonCard } from './card'; 7 | 8 | export function SkeletonHome() { 9 | return ( 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {Array.from({ length: Constants.INITIAL_ITEM_RENDER }).map((_, i) => { 21 | return ( 22 | 23 | 24 | 25 | 26 | ); 27 | })} 28 | 29 | 30 | 31 | 32 | {Array.from({ length: Constants.INITIAL_ITEM_RENDER }).map((_, i) => { 33 | return ; 34 | })} 35 | 36 | ); 37 | } 38 | 39 | const styles = StyleSheet.create({ 40 | container: { 41 | flex: 1, 42 | paddingTop: Constants.STATUS_BAR_HEIGHT, 43 | }, 44 | header: { 45 | flexDirection: 'row', 46 | alignItems: 'center', 47 | justifyContent: 'space-between', 48 | padding: 15, 49 | }, 50 | headerLeft: { 51 | flexDirection: 'row', 52 | alignItems: 'center', 53 | }, 54 | headerTitle: { 55 | marginHorizontal: 10, 56 | borderRadius: 999, 57 | width: 100, 58 | }, 59 | smallIcon: { 60 | width: 30, 61 | height: 30, 62 | borderRadius: 15, 63 | }, 64 | icon: { 65 | width: Constants.SHORTCUT_ICON_SIZE, 66 | height: Constants.SHORTCUT_ICON_SIZE, 67 | borderRadius: Constants.SHORTCUT_ICON_SIZE / 2, 68 | }, 69 | label: { 70 | width: Constants.SHORTCUT_ICON_SIZE / 2, 71 | marginTop: 2.4, 72 | borderRadius: 999, 73 | }, 74 | shortcuts: { 75 | width: '100%', 76 | marginVertical: 15, 77 | }, 78 | shortcutList: { 79 | paddingHorizontal: 15, 80 | alignItems: 'center', 81 | flexDirection: 'row', 82 | }, 83 | shortcutContent: { 84 | alignItems: 'center', 85 | marginRight: 15, 86 | }, 87 | activities: { 88 | width: ScreenWidth(100) - 30, 89 | marginVertical: 15, 90 | height: 250, 91 | borderRadius: 25, 92 | alignSelf: 'center', 93 | }, 94 | }); 95 | -------------------------------------------------------------------------------- /src/utils/container.ts: -------------------------------------------------------------------------------- 1 | import {FlatList, View} from 'react-native'; 2 | import {createShimmerPlaceholder} from 'react-native-shimmer-placeholder'; 3 | import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'; 4 | import Animated from 'react-native-reanimated'; 5 | import LinearGradient from 'react-native-linear-gradient'; 6 | 7 | export const ShimmerPlaceholder = createShimmerPlaceholder(LinearGradient); 8 | export const AnimatedShimmerPlaceholder = 9 | Animated.createAnimatedComponent(ShimmerPlaceholder); 10 | export const AnimatedFlatList = Animated.createAnimatedComponent(FlatList); 11 | export const AnimatedHeaderComponent = 12 | Animated.createAnimatedComponent(LinearGradient); 13 | export const AnimatedView = Animated.createAnimatedComponent(View); 14 | export const AnimatedIcon = Animated.createAnimatedComponent( 15 | MaterialCommunityIcons, 16 | ); 17 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import moment from 'moment'; 2 | 3 | export function FirstCase(text: string) { 4 | return text.charAt(0).toUpperCase() + text.slice(1); 5 | } 6 | 7 | export function LimitCase(text: string, size: number) { 8 | return text.length < size ? text : `${text.substring(0, size - 2)}..`; 9 | } 10 | 11 | export function ExtractNumbers(text: string) { 12 | var num = text.replace(/[^0-9]/g, ''); 13 | var result = parseInt(num, 10); 14 | return isNaN(result) ? 0 : result; 15 | } 16 | 17 | export function sleep(ms: number): Promise { 18 | return new Promise(resolve => setTimeout(resolve, ms)); 19 | } 20 | 21 | export const percentageOff = ( 22 | mode: string, 23 | price: number, 24 | percentageValue: number, 25 | ): number => { 26 | return mode === 'percent' 27 | ? Number(price * (1 - percentageValue / 100)) 28 | : Number(price - percentageValue); 29 | }; 30 | 31 | export function getRandomColor() { 32 | var letters = '0123456789ABCDEF'; 33 | var color = '#'; 34 | for (var i = 0; i < 6; i++) { 35 | color += letters[Math.floor(Math.random() * 16)]; 36 | } 37 | return color; 38 | } 39 | 40 | export function combinedDate(date: any, time: any) { 41 | return new Date(date).setHours( 42 | new Date(time).getHours(), 43 | new Date(time).getMinutes(), 44 | new Date(time).getSeconds(), 45 | ); 46 | } 47 | 48 | export function betweenDays(days: number) { 49 | const beforeIsoString = moment().subtract(days, 'days').toISOString(); 50 | const start = new Date(beforeIsoString).getTime(); 51 | const end = new Date().getTime(); 52 | 53 | return { start, end }; 54 | } 55 | 56 | export function ISODate(date: any) { 57 | return new Date(date).toISOString(); 58 | } 59 | 60 | export const validateEmail = (email: string) => { 61 | return String(email) 62 | .toLowerCase() 63 | .match( 64 | /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, 65 | ); 66 | }; 67 | -------------------------------------------------------------------------------- /src/utils/layout.ts: -------------------------------------------------------------------------------- 1 | // packages 2 | import { Dimensions, PixelRatio } from "react-native"; 3 | 4 | // Retrieve initial screen's width 5 | let screenWidth = Dimensions.get("window").width; 6 | 7 | // Retrieve initial screen's height 8 | let screenHeight = Dimensions.get("window").height; 9 | 10 | /** 11 | * Converts provided width percentage to independent pixel (dp). 12 | * @param {string} widthPercent The percentage of screen's width that UI element should cover 13 | * along with the percentage symbol (%). 14 | * @return {number} The calculated dp depending on current device's screen width. 15 | */ 16 | const widthPercentageToDP = (widthPercent: number | string) => { 17 | // Parse string percentage input and convert it to number. 18 | const elemWidth = 19 | typeof widthPercent === "number" ? widthPercent : parseFloat(widthPercent); 20 | 21 | // Use PixelRatio.roundToNearestPixel method in order to round the layout 22 | // size (dp) to the nearest one that correspons to an integer number of pixels. 23 | return PixelRatio.roundToNearestPixel((screenWidth * elemWidth) / 100); 24 | }; 25 | 26 | /** 27 | * Converts provided height percentage to independent pixel (dp). 28 | * @param {string} heightPercent The percentage of screen's height that UI element should cover 29 | * along with the percentage symbol (%). 30 | * @return {number} The calculated dp depending on current device's screen height. 31 | */ 32 | const heightPercentageToDP = (heightPercent: number | string) => { 33 | // Parse string percentage input and convert it to number. 34 | const elemHeight = 35 | typeof heightPercent === "number" 36 | ? heightPercent 37 | : parseFloat(heightPercent); 38 | 39 | // Use PixelRatio.roundToNearestPixel method in order to round the layout 40 | // size (dp) to the nearest one that correspons to an integer number of pixels. 41 | return PixelRatio.roundToNearestPixel((screenHeight * elemHeight) / 100); 42 | }; 43 | 44 | export { 45 | widthPercentageToDP as ScreenWidth, 46 | heightPercentageToDP as ScreenHeight, 47 | }; 48 | --------------------------------------------------------------------------------