├── .buckconfig ├── .editorconfig ├── .eslintrc.js ├── .example.env ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .prettierrc.js ├── .watchmanconfig ├── LICENSE ├── 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 │ │ │ └── moodlemobile │ │ │ └── ReactNativeFlipper.java │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── assets │ │ └── fonts │ │ │ ├── AntDesign.ttf │ │ │ ├── Entypo.ttf │ │ │ ├── EvilIcons.ttf │ │ │ ├── Feather.ttf │ │ │ ├── FontAwesome.ttf │ │ │ ├── FontAwesome5_Brands.ttf │ │ │ ├── FontAwesome5_Regular.ttf │ │ │ ├── FontAwesome5_Solid.ttf │ │ │ ├── Fontisto.ttf │ │ │ ├── Foundation.ttf │ │ │ ├── Ionicons.ttf │ │ │ ├── MaterialCommunityIcons.ttf │ │ │ ├── MaterialIcons.ttf │ │ │ ├── Octicons.ttf │ │ │ ├── Roboto-Black.ttf │ │ │ ├── Roboto-BlackItalic.ttf │ │ │ ├── Roboto-Bold.ttf │ │ │ ├── Roboto-BoldItalic.ttf │ │ │ ├── Roboto-Italic.ttf │ │ │ ├── Roboto-Light.ttf │ │ │ ├── Roboto-LightItalic.ttf │ │ │ ├── Roboto-Medium.ttf │ │ │ ├── Roboto-MediumItalic.ttf │ │ │ ├── Roboto-Regular.ttf │ │ │ ├── Roboto-Thin.ttf │ │ │ ├── Roboto-ThinItalic.ttf │ │ │ ├── SimpleLineIcons.ttf │ │ │ └── Zocial.ttf │ │ ├── java │ │ └── com │ │ │ └── moodlemobile │ │ │ ├── MainActivity.java │ │ │ └── MainApplication.java │ │ └── res │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── app.json ├── assets └── fonts │ ├── Roboto-Black.ttf │ ├── Roboto-BlackItalic.ttf │ ├── Roboto-Bold.ttf │ ├── Roboto-BoldItalic.ttf │ ├── Roboto-Italic.ttf │ ├── Roboto-Light.ttf │ ├── Roboto-LightItalic.ttf │ ├── Roboto-Medium.ttf │ ├── Roboto-MediumItalic.ttf │ ├── Roboto-Regular.ttf │ ├── Roboto-Thin.ttf │ └── Roboto-ThinItalic.ttf ├── babel.config.js ├── docs └── assets │ ├── screenshot-1.png │ ├── screenshot-2.png │ └── screenshot-3.png ├── index.js ├── ios ├── LaunchScreen.storyboard ├── MoodleMobile.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── MoodleMobile.xcscheme ├── MoodleMobile.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── MoodleMobile │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Info.plist │ ├── LaunchScreen.storyboard │ ├── main.m │ └── pt-BR.lproj │ │ └── LaunchScreen.strings ├── MoodleMobileTests │ ├── Info.plist │ └── MoodleMobileTests.m ├── Podfile └── Podfile.lock ├── metro.config.js ├── package.json ├── react-native.config.js ├── src ├── App.js ├── RootNavigation.js ├── api │ ├── constants.js │ └── helper.js ├── blocks │ ├── index.js │ ├── myoverview │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ ├── notfound │ │ ├── index.js │ │ └── styles.js │ ├── recentlyaccessedcourses │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ └── timeline │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js ├── components │ ├── Dialog │ │ └── index.js │ ├── LoadingIndicator │ │ ├── index.js │ │ └── styles.js │ ├── Page │ │ ├── index.js │ │ └── styles.js │ └── index.js ├── events │ ├── course.js │ ├── index.js │ ├── module.js │ └── user.js ├── locales │ ├── en.json │ ├── index.js │ └── pt-br.json ├── modules │ ├── feedback │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ ├── index.js │ ├── notfound │ │ ├── index.js │ │ └── styles.js │ ├── page │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ └── resource │ │ ├── index.js │ │ └── provider.js └── screens │ ├── AuthContext │ ├── Login │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ ├── Register │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ └── index.js │ ├── ContextManager.js │ ├── CourseContext │ ├── View │ │ ├── Activities │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ ├── Participants │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ ├── index.js │ │ └── provider.js │ └── index.js │ ├── DashboardContext │ ├── About │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ ├── AboutSubcontext │ │ ├── BlogMessages │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ ├── Details │ │ │ ├── index.js │ │ │ └── provider.js │ │ ├── Grades │ │ │ ├── View │ │ │ │ └── index.js │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ ├── Profile │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ └── index.js │ ├── Dashboard │ │ ├── index.js │ │ └── provider.js │ ├── Messages │ │ ├── index.js │ │ ├── provider.js │ │ └── styles.js │ ├── MessagesSubcontext │ │ ├── Settings │ │ │ ├── index.js │ │ │ └── styles.js │ │ ├── View │ │ │ ├── index.js │ │ │ ├── provider.js │ │ │ └── styles.js │ │ └── index.js │ ├── index.js │ └── provider.js │ └── index.js └── yarn.lock /.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /.example.env: -------------------------------------------------------------------------------- 1 | MOODLE_HOST=localhost 2 | MOODLE_SERVICE=moodle_mobile_app 3 | MOODLE_ADMIN_TOKEN=ADMIN TOKEN GOES HERE 4 | MOODLE_WSEXTSERVICE=local_mobile 5 | MOODLE_CUSTOMURLSCHEME=moodlemobile 6 | -------------------------------------------------------------------------------- /.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 | esproposal.optional_chaining=enable 27 | esproposal.nullish_coalescing=enable 28 | 29 | exact_by_default=true 30 | 31 | module.file_ext=.js 32 | module.file_ext=.json 33 | module.file_ext=.ios.js 34 | 35 | munge_underscores=true 36 | 37 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 38 | 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' 39 | 40 | suppress_type=$FlowIssue 41 | suppress_type=$FlowFixMe 42 | suppress_type=$FlowFixMeProps 43 | suppress_type=$FlowFixMeState 44 | 45 | [lints] 46 | sketchy-null-number=warn 47 | sketchy-null-mixed=warn 48 | sketchy-number=warn 49 | untyped-type-import=warn 50 | nonstrict-import=warn 51 | deprecated-type=warn 52 | unsafe-getters-setters=warn 53 | unnecessary-invariant=warn 54 | signature-verification-failure=warn 55 | 56 | [strict] 57 | deprecated-type 58 | nonstrict-import 59 | sketchy-null 60 | unclear-type 61 | unsafe-getters-setters 62 | untyped-import 63 | untyped-type-import 64 | 65 | [version] 66 | ^0.137.0 67 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.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 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | 61 | .env -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Vinicius Costa Castro 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-moodlemobile 2 | ## A React Native application developed to work with Moodle. 3 | 4 | ### How to run: 5 | * Clone the repository and access it 6 | * Install the dependencies with: `npm install` or `yarn install` 7 | * Create your `.env` file based on `.example.env`, and fill in the information from your moodle site information 8 | * If you want to run on an iOS device, access `ios/` and install the pods with: `cd ios` and `pod install` 9 | * Run the application with: `react-native run-ios` or `react-native run-android` 10 | 11 | ### Environment variables 12 | 13 | The .env file is where you will inform information about your instance 14 | 15 | * MOODLE_HOST: is the URL of your moodle instance. 16 | * MOODLE_SERVICE: Moodle services are specified in plugins > external services. Enter here which service you want to use. Commonly the service to be used is moodle_mobile_app. 17 | * MOODLE_ADMIN_TOKEN: Enter the token generated by the administrator. To generate, go to plugins > manage tokens 18 | 19 | ### Project structure 20 | 21 | The project is divided into the following structure 22 | 23 | * src 24 | * api: This directory contains all files related to calls to the moodle webservice. This facilitates the implementation of new calls and the maintenance of existing ones. 25 | * blocks: Here all the blocks to be used by the application, if you have a proprietary moodle block and want to use it in your application, you must implement it here. 26 | * components: Here are React Components commonly used by the application. 27 | * events: Here all the files related to the events emitted by the application. 28 | * locales: All files related to the internationalization of the application are here 29 | * modules: This is where the moodle educational modules are implemented 30 | * screens: Everything you can see on your device's screen is here. 31 | 32 | ### Application screenshots 33 | 34 | ![screenshot-1](https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/develop/docs/assets/screenshot-1.png) ![screenshot-2](https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/develop/docs/assets/screenshot-2.png) ![screenshot-3](https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/develop/docs/assets/screenshot-3.png) -------------------------------------------------------------------------------- /__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.moodlemobile", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.moodlemobile", 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.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation. If none specified and 19 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 20 | * // default. Can be overridden with ENTRY_FILE environment variable. 21 | * entryFile: "index.android.js", 22 | * 23 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 24 | * bundleCommand: "ram-bundle", 25 | * 26 | * // whether to bundle JS and assets in debug mode 27 | * bundleInDebug: false, 28 | * 29 | * // whether to bundle JS and assets in release mode 30 | * bundleInRelease: true, 31 | * 32 | * // whether to bundle JS and assets in another build variant (if configured). 33 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 34 | * // The configuration property can be in the following formats 35 | * // 'bundleIn${productFlavor}${buildType}' 36 | * // 'bundleIn${buildType}' 37 | * // bundleInFreeDebug: true, 38 | * // bundleInPaidRelease: true, 39 | * // bundleInBeta: true, 40 | * 41 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 42 | * // for example: to disable dev mode in the staging build type (if configured) 43 | * devDisabledInStaging: true, 44 | * // The configuration property can be in the following formats 45 | * // 'devDisabledIn${productFlavor}${buildType}' 46 | * // 'devDisabledIn${buildType}' 47 | * 48 | * // the root of your project, i.e. where "package.json" lives 49 | * root: "../../", 50 | * 51 | * // where to put the JS bundle asset in debug mode 52 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 53 | * 54 | * // where to put the JS bundle asset in release mode 55 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 56 | * 57 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 58 | * // require('./image.png')), in debug mode 59 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 60 | * 61 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 62 | * // require('./image.png')), in release mode 63 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 64 | * 65 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 66 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 67 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 68 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 69 | * // for example, you might want to remove it from here. 70 | * inputExcludes: ["android/**", "ios/**"], 71 | * 72 | * // override which node gets called and with what additional arguments 73 | * nodeExecutableAndArgs: ["node"], 74 | * 75 | * // supply additional arguments to the packager 76 | * extraPackagerArgs: [] 77 | * ] 78 | */ 79 | 80 | project.ext.react = [ 81 | enableHermes: false, // clean and rebuild if changing 82 | ] 83 | 84 | apply from: "../../node_modules/react-native/react.gradle" 85 | 86 | /** 87 | * Set this to true to create two separate APKs instead of one: 88 | * - An APK that only works on ARM devices 89 | * - An APK that only works on x86 devices 90 | * The advantage is the size of the APK is reduced by about 4MB. 91 | * Upload all the APKs to the Play Store and people will download 92 | * the correct one based on the CPU architecture of their device. 93 | */ 94 | def enableSeparateBuildPerCPUArchitecture = false 95 | 96 | /** 97 | * Run Proguard to shrink the Java bytecode in release builds. 98 | */ 99 | def enableProguardInReleaseBuilds = false 100 | 101 | /** 102 | * The preferred build flavor of JavaScriptCore. 103 | * 104 | * For example, to use the international variant, you can use: 105 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 106 | * 107 | * The international variant includes ICU i18n library and necessary data 108 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 109 | * give correct results when using with locales other than en-US. Note that 110 | * this variant is about 6MiB larger per architecture than default. 111 | */ 112 | def jscFlavor = 'org.webkit:android-jsc:+' 113 | 114 | /** 115 | * Whether to enable the Hermes VM. 116 | * 117 | * This should be set on project.ext.react and mirrored here. If it is not set 118 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 119 | * and the benefits of using Hermes will therefore be sharply reduced. 120 | */ 121 | def enableHermes = project.ext.react.get("enableHermes", false); 122 | 123 | android { 124 | ndkVersion rootProject.ext.ndkVersion 125 | 126 | compileSdkVersion rootProject.ext.compileSdkVersion 127 | 128 | compileOptions { 129 | sourceCompatibility JavaVersion.VERSION_1_8 130 | targetCompatibility JavaVersion.VERSION_1_8 131 | } 132 | 133 | defaultConfig { 134 | applicationId "com.moodlemobile" 135 | minSdkVersion rootProject.ext.minSdkVersion 136 | targetSdkVersion rootProject.ext.targetSdkVersion 137 | versionCode 1 138 | versionName "1.0" 139 | } 140 | splits { 141 | abi { 142 | reset() 143 | enable enableSeparateBuildPerCPUArchitecture 144 | universalApk false // If true, also generate a universal APK 145 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 146 | } 147 | } 148 | signingConfigs { 149 | debug { 150 | storeFile file('debug.keystore') 151 | storePassword 'android' 152 | keyAlias 'androiddebugkey' 153 | keyPassword 'android' 154 | } 155 | } 156 | buildTypes { 157 | debug { 158 | signingConfig signingConfigs.debug 159 | } 160 | release { 161 | // Caution! In production, you need to generate your own keystore file. 162 | // see https://reactnative.dev/docs/signed-apk-android. 163 | signingConfig signingConfigs.debug 164 | minifyEnabled enableProguardInReleaseBuilds 165 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 166 | } 167 | } 168 | 169 | // applicationVariants are e.g. debug, release 170 | applicationVariants.all { variant -> 171 | variant.outputs.each { output -> 172 | // For each separate APK per architecture, set a unique version code as described here: 173 | // https://developer.android.com/studio/build/configure-apk-splits.html 174 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 175 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 176 | def abi = output.getFilter(OutputFile.ABI) 177 | if (abi != null) { // null for the universal-debug, universal-release variants 178 | output.versionCodeOverride = 179 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 180 | } 181 | 182 | } 183 | } 184 | } 185 | 186 | dependencies { 187 | implementation fileTree(dir: "libs", include: ["*.jar"]) 188 | //noinspection GradleDynamicVersion 189 | implementation "com.facebook.react:react-native:+" // From node_modules 190 | 191 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 192 | 193 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 194 | exclude group:'com.facebook.fbjni' 195 | } 196 | 197 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 198 | exclude group:'com.facebook.flipper' 199 | exclude group:'com.squareup.okhttp3', module:'okhttp' 200 | } 201 | 202 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 203 | exclude group:'com.facebook.flipper' 204 | } 205 | 206 | if (enableHermes) { 207 | def hermesPath = "../../node_modules/hermes-engine/android/"; 208 | debugImplementation files(hermesPath + "hermes-debug.aar") 209 | releaseImplementation files(hermesPath + "hermes-release.aar") 210 | } else { 211 | implementation jscFlavor 212 | } 213 | } 214 | 215 | // Run this once to be able to run the application with BUCK 216 | // puts all compile dependencies into folder libs for BUCK to use 217 | task copyDownloadableDepsToLibs(type: Copy) { 218 | from configurations.compile 219 | into 'libs' 220 | } 221 | 222 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 223 | -------------------------------------------------------------------------------- /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/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/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 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/app/src/debug/java/com/moodlemobile/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.moodlemobile; 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 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/AntDesign.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/AntDesign.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Entypo.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Entypo.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/EvilIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/EvilIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Feather.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Feather.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/FontAwesome.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/FontAwesome.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Fontisto.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Fontisto.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Foundation.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Foundation.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Ionicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Ionicons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/MaterialIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/MaterialIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Octicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Octicons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Black.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Bold.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Italic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Light.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-Thin.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/SimpleLineIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/SimpleLineIcons.ttf -------------------------------------------------------------------------------- /android/app/src/main/assets/fonts/Zocial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/assets/fonts/Zocial.ttf -------------------------------------------------------------------------------- /android/app/src/main/java/com/moodlemobile/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.moodlemobile; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "MoodleMobile"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/moodlemobile/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.moodlemobile; 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 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for example: 28 | // packages.add(new MyReactNativePackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 53 | * 54 | * @param context 55 | * @param reactInstanceManager 56 | */ 57 | private static void initializeFlipper( 58 | Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | We use reflection here to pick up the class that initializes Flipper, 63 | since Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("com.moodlemobile.ReactNativeFlipper"); 66 | aClass 67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 68 | .invoke(null, context, reactInstanceManager); 69 | } catch (ClassNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) { 74 | e.printStackTrace(); 75 | } catch (InvocationTargetException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MoodleMobile 3 | 4 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /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 = "29.0.3" 6 | minSdkVersion = 21 7 | compileSdkVersion = 31 8 | targetSdkVersion = 31 9 | ndkVersion = "20.1.5948944" 10 | androidXBrowser = "1.3.0" // Adding this property will avoid defaultAndroidXVersion 11 | } 12 | repositories { 13 | google() 14 | jcenter() 15 | } 16 | dependencies { 17 | classpath("com.android.tools.build:gradle:4.1.0") 18 | // NOTE: Do not place your application dependencies here; they belong 19 | // in the individual module build.gradle files 20 | } 21 | } 22 | 23 | def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) 24 | 25 | allprojects { 26 | repositories { 27 | mavenLocal() 28 | maven { 29 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 30 | url("$rootDir/../node_modules/react-native/android") 31 | } 32 | maven { 33 | // Android JSC is installed from npm 34 | url("$rootDir/../node_modules/jsc-android/dist") 35 | } 36 | 37 | google() 38 | jcenter() 39 | maven { url 'https://www.jitpack.io' } 40 | } 41 | 42 | configurations.all { 43 | resolutionStrategy { 44 | // Remove this override in 0.66, as a proper fix is included in react-native itself. 45 | force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /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: -Xmx10248m -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.75.1 29 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/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-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" -------------------------------------------------------------------------------- /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 Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto execute 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto execute 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :execute 65 | @rem Setup the command line 66 | 67 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 68 | 69 | 70 | @rem Execute Gradle 71 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 72 | 73 | :end 74 | @rem End local scope for the variables with windows NT shell 75 | if "%ERRORLEVEL%"=="0" goto mainEnd 76 | 77 | :fail 78 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 79 | rem the _cmd.exe /c_ return code! 80 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 81 | exit /b 1 82 | 83 | :mainEnd 84 | if "%OS%"=="Windows_NT" endlocal 85 | 86 | :omega 87 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MoodleMobile' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MoodleMobile", 3 | "displayName": "MoodleMobile" 4 | } -------------------------------------------------------------------------------- /assets/fonts/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Black.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-BlackItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Bold.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-BoldItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Italic.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Light.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-LightItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-MediumItalic.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Regular.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-Thin.ttf -------------------------------------------------------------------------------- /assets/fonts/Roboto-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/assets/fonts/Roboto-ThinItalic.ttf -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | 'module:metro-react-native-babel-preset', 4 | 'module:react-native-dotenv', 5 | ], 6 | env: { 7 | production: { 8 | plugins: ['react-native-paper/babel'], 9 | }, 10 | }, 11 | }; 12 | -------------------------------------------------------------------------------- /docs/assets/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/docs/assets/screenshot-1.png -------------------------------------------------------------------------------- /docs/assets/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/docs/assets/screenshot-2.png -------------------------------------------------------------------------------- /docs/assets/screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/costvin15/react-native-moodlemobile/436a9af29cca335bb71ab4d35fdea52166f99e4a/docs/assets/screenshot-3.png -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import 'react-native-gesture-handler'; 2 | import {AppRegistry} from 'react-native'; 3 | import App from './src/App'; 4 | import {name as appName} from './app.json'; 5 | 6 | AppRegistry.registerComponent(appName, () => App); 7 | -------------------------------------------------------------------------------- /ios/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /ios/MoodleMobile.xcodeproj/xcshareddata/xcschemes/MoodleMobile.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/MoodleMobile.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/MoodleMobile.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/MoodleMobile/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/MoodleMobile/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | * This source code is licensed under the MIT license found in the 5 | * LICENSE file in the root directory of this source tree. 6 | */ 7 | 8 | #import "AppDelegate.h" 9 | 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 20 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 21 | moduleName:@"MoodleMobile" 22 | initialProperties:nil]; 23 | 24 | if (@available(iOS 13.0, *)) { 25 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 26 | } else { 27 | rootView.backgroundColor = [UIColor whiteColor]; 28 | } 29 | 30 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 31 | UIViewController *rootViewController = [UIViewController new]; 32 | rootViewController.view = rootView; 33 | self.window.rootViewController = rootViewController; 34 | [self.window makeKeyAndVisible]; 35 | return YES; 36 | } 37 | 38 | -(BOOL)applcation:(UIApplication *)application openURL:(NSURL *)url 39 | sourceApplication:(NSString *)sourceApplication annotation:(id)annotation 40 | { 41 | return [RCTLinkingManager application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; 42 | } 43 | 44 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 45 | { 46 | #if DEBUG 47 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 48 | #else 49 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 50 | #endif 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /ios/MoodleMobile/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /ios/MoodleMobile/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /ios/MoodleMobile/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | MoodleMobile 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 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLName 29 | moodlemobile 30 | CFBundleURLSchemes 31 | 32 | moodlemobile 33 | 34 | 35 | 36 | CFBundleVersion 37 | 1 38 | LSRequiresIPhoneOS 39 | 40 | NSAppTransportSecurity 41 | 42 | NSExceptionDomains 43 | 44 | localhost 45 | 46 | NSExceptionAllowsInsecureHTTPLoads 47 | 48 | 49 | 50 | 51 | NSLocationWhenInUseUsageDescription 52 | 53 | UIAppFonts 54 | 55 | MaterialCommunityIcons.ttf 56 | MaterialIcons.ttf 57 | Roboto-Black.ttf 58 | Roboto-BlackItalic.ttf 59 | Roboto-Bold.ttf 60 | Roboto-BoldItalic.ttf 61 | Roboto-Italic.ttf 62 | Roboto-Light.ttf 63 | Roboto-LightItalic.ttf 64 | Roboto-Medium.ttf 65 | Roboto-MediumItalic.ttf 66 | Roboto-Regular.ttf 67 | Roboto-Thin.ttf 68 | Roboto-ThinItalic.ttf 69 | 70 | UILaunchStoryboardName 71 | LaunchScreen 72 | UIRequiredDeviceCapabilities 73 | 74 | armv7 75 | 76 | UISupportedInterfaceOrientations 77 | 78 | UIInterfaceOrientationPortrait 79 | UIInterfaceOrientationLandscapeLeft 80 | UIInterfaceOrientationLandscapeRight 81 | 82 | UIViewControllerBasedStatusBarAppearance 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /ios/MoodleMobile/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /ios/MoodleMobile/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/MoodleMobile/pt-BR.lproj/LaunchScreen.strings: -------------------------------------------------------------------------------- 1 | 2 | /* Class = "UILabel"; text = "Powered by React Native"; ObjectID = "8ie-xW-0ye"; */ 3 | "8ie-xW-0ye.text" = "Powered by React Native"; 4 | 5 | /* Class = "UILabel"; text = "MoodleMobile"; ObjectID = "kId-c2-rCX"; */ 6 | "kId-c2-rCX.text" = "MoodleMobile"; 7 | -------------------------------------------------------------------------------- /ios/MoodleMobileTests/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/MoodleMobileTests/MoodleMobileTests.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 MoodleMobileTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation MoodleMobileTests 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 | -------------------------------------------------------------------------------- /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, '10.0' 5 | 6 | target 'MoodleMobile' 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 'MoodleMobileTests' 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 | # post_install do |installer| 26 | # react_native_post_install(installer) 27 | # end 28 | end -------------------------------------------------------------------------------- /metro.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | 8 | module.exports = { 9 | transformer: { 10 | getTransformOptions: async () => ({ 11 | transform: { 12 | experimentalImportSupport: false, 13 | inlineRequires: true, 14 | }, 15 | }), 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MoodleMobile", 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 | "@react-native-community/async-storage": "1.8.1", 14 | "@react-native-community/masked-view": "0.1.7", 15 | "@react-native-community/toolbar-android": "0.1.0-rc.2", 16 | "@react-navigation/drawer": "5.12.3", 17 | "@react-navigation/material-bottom-tabs": "5.3.13", 18 | "@react-navigation/material-top-tabs": "5.3.13", 19 | "@react-navigation/native": "5.9.2", 20 | "@react-navigation/stack": "5.14.2", 21 | "moment": "2.24.0", 22 | "node-fetch": "2.6.1", 23 | "react": "17.0.1", 24 | "react-native": "0.64.2", 25 | "react-native-collapsible": "1.5.2", 26 | "react-native-dotenv": "0.2.0", 27 | "react-native-gesture-handler": "1.6.1", 28 | "react-native-gifted-chat": "0.13.0", 29 | "react-native-i18n": "2.0.15", 30 | "react-native-inappbrowser-reborn": "3.4.0", 31 | "react-native-linear-gradient": "2.5.6", 32 | "react-native-paper": "3.10.1", 33 | "react-native-reanimated": "1.7.1", 34 | "react-native-render-html": "4.2.0", 35 | "react-native-safe-area-context": "0.7.3", 36 | "react-native-screens": "2.4.0", 37 | "react-native-share": "3.3.0", 38 | "react-native-skeleton-placeholder": "2.0.7", 39 | "react-native-tab-view": "2.13.0", 40 | "react-native-vector-icons": "6.6.0", 41 | "react-native-webview": "11.2.1", 42 | "rn-fetch-blob": "0.12.0" 43 | }, 44 | "devDependencies": { 45 | "@babel/core": "7.12.9", 46 | "@babel/runtime": "7.12.5", 47 | "@react-native-community/eslint-config": "2.0.0", 48 | "babel-jest": "26.6.3", 49 | "eslint": "7.14.0", 50 | "jest": "26.6.3", 51 | "metro-react-native-babel-preset": "0.64.0", 52 | "react-test-renderer": "17.0.1" 53 | }, 54 | "jest": { 55 | "preset": "react-native" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /react-native.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | project: { 3 | ios: {}, 4 | android: {}, 5 | }, 6 | assets: ['./assets/fonts/'], 7 | }; 8 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {NavigationContainer} from '@react-navigation/native'; 3 | import {createStackNavigator} from '@react-navigation/stack'; 4 | import {Provider, DefaultTheme} from 'react-native-paper'; 5 | 6 | import { 7 | AuthContext, 8 | ContextManager, 9 | CourseContext, 10 | DashboardContext, 11 | AboutSubcontext, 12 | MessagesSubcontext, 13 | } from './screens'; 14 | import Modules from './modules'; 15 | import {navigationRef} from './RootNavigation'; 16 | 17 | const App = () => { 18 | const Stack = createStackNavigator(); 19 | 20 | return ( 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 32 | 33 | 34 | 35 | ); 36 | }; 37 | 38 | const Main = () => { 39 | const theme = { 40 | ...DefaultTheme, 41 | colors: { 42 | ...DefaultTheme.colors, 43 | }, 44 | }; 45 | 46 | return ( 47 | 48 | 49 | 50 | ); 51 | }; 52 | 53 | export default Main; 54 | -------------------------------------------------------------------------------- /src/RootNavigation.js: -------------------------------------------------------------------------------- 1 | import React, {createRef} from 'react'; 2 | 3 | export const navigationRef = createRef(); 4 | export const navigate = (name, params) => { 5 | if (navigationRef.current) { 6 | navigationRef.current.navigate(name, params); 7 | } 8 | }; 9 | 10 | export default {navigate}; 11 | -------------------------------------------------------------------------------- /src/api/constants.js: -------------------------------------------------------------------------------- 1 | import { 2 | MOODLE_HOST, 3 | MOODLE_SERVICE, 4 | MOODLE_ADMIN_TOKEN, 5 | MOODLE_WSEXTSERVICE, 6 | MOODLE_CUSTOMURLSCHEME, 7 | } from 'react-native-dotenv'; 8 | 9 | export default { 10 | MOODLE_HOST, 11 | MOODLE_SERVICE, 12 | MOODLE_ADMIN_TOKEN, 13 | MOODLE_WSEXTSERVICE, 14 | MOODLE_CUSTOMURLSCHEME, 15 | MOODLE_USER_TOKEN: 'MOODLE_USER_TOKEN', 16 | MOODLE_USER_DETAILS: 'MOODLE_USER_DETAILS', 17 | }; 18 | -------------------------------------------------------------------------------- /src/api/helper.js: -------------------------------------------------------------------------------- 1 | import AsyncStorage from '@react-native-community/async-storage'; 2 | import Constants from './constants'; 3 | import events from '../events'; 4 | 5 | export const callMoodleWebService = async (wsfunction, ...params) => { 6 | let url = `${ 7 | Constants.MOODLE_HOST 8 | }/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=${wsfunction}`; 9 | 10 | if (typeof params.wstoken === 'undefined') { 11 | const token = await AsyncStorage.getItem(Constants.MOODLE_USER_TOKEN); 12 | if (token) { 13 | url += `&wstoken=${token}`; 14 | } 15 | } 16 | 17 | params.forEach(param => { 18 | Object.keys(param).forEach(key => { 19 | if (Array.isArray(param[key])) { 20 | param[key].forEach((value, index) => { 21 | if (typeof value === 'object') { 22 | Object.keys(value).forEach(valuekey => { 23 | url += `&${key}[${index}][${valuekey}]=${value[valuekey]}`; 24 | }); 25 | } else { 26 | url += `&${key}[${index}]=${value}`; 27 | } 28 | }); 29 | } else { 30 | url += `&${key}=${param[key]}`; 31 | } 32 | }); 33 | }); 34 | 35 | const response = await fetch(url); 36 | const data = await response.json(); 37 | 38 | if (data?.errorcode) { 39 | throw data; 40 | } 41 | 42 | return data; 43 | }; 44 | 45 | export const updateCurrentUserDetails = async () => { 46 | const {sitename, functions, ...userdata} = await callMoodleWebService( 47 | 'core_webservice_get_site_info', 48 | ); 49 | 50 | await AsyncStorage.setItem( 51 | Constants.MOODLE_USER_DETAILS, 52 | JSON.stringify(userdata), 53 | ); 54 | }; 55 | 56 | export const getCurrentUserDetails = async () => { 57 | const userdata = await AsyncStorage.getItem(Constants.MOODLE_USER_DETAILS); 58 | return JSON.parse(userdata); 59 | }; 60 | 61 | export const getUserCourses = async () => { 62 | const {userid} = await getCurrentUserDetails(); 63 | const response = await callMoodleWebService('core_enrol_get_users_courses', { 64 | userid, 65 | }); 66 | return response; 67 | }; 68 | 69 | export const renewMoodleUserToken = async ({username, password}) => { 70 | const response = await fetch( 71 | `${Constants.MOODLE_HOST}/login/token.php?service=${ 72 | Constants.MOODLE_SERVICE 73 | }&username=${username}&password=${password}`, 74 | ); 75 | const data = await response.json(); 76 | 77 | if (data.errorcode) { 78 | throw data; 79 | } 80 | 81 | await AsyncStorage.setItem(Constants.MOODLE_USER_TOKEN, data.token); 82 | await updateCurrentUserDetails(); 83 | 84 | return data.token; 85 | }; 86 | 87 | export const setMoodleUserToken = async token => { 88 | await AsyncStorage.setItem(Constants.MOODLE_USER_TOKEN, token); 89 | // await updateCurrentUserDetails(); 90 | return token; 91 | }; 92 | 93 | export const getMoodleUserToken = async () => { 94 | const token = await AsyncStorage.getItem(Constants.MOODLE_USER_TOKEN); 95 | return token; 96 | }; 97 | 98 | export const emmitEvent = (eventname, params) => { 99 | const {handler} = events.find(event => event?.name === eventname); 100 | handler(params); 101 | }; 102 | 103 | export default { 104 | callMoodleWebService, 105 | updateCurrentUserDetails, 106 | getCurrentUserDetails, 107 | getUserCourses, 108 | renewMoodleUserToken, 109 | setMoodleUserToken, 110 | getMoodleUserToken, 111 | emmitEvent, 112 | }; 113 | -------------------------------------------------------------------------------- /src/blocks/index.js: -------------------------------------------------------------------------------- 1 | export {default as NotFound} from './notfound'; 2 | export {default as Timeline} from './timeline'; 3 | export {default as RecentlyAccessedCourses} from './recentlyaccessedcourses'; 4 | export {default as MyOverview} from './myoverview'; 5 | -------------------------------------------------------------------------------- /src/blocks/myoverview/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Card, ProgressBar} from 'react-native-paper'; 3 | import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; 4 | import SkeletonPlaceholder from 'react-native-skeleton-placeholder'; 5 | import {View, FlatList, Image, Text, TouchableOpacity} from 'react-native'; 6 | import i18n from 'react-native-i18n'; 7 | 8 | import Provider from './provider'; 9 | import {styles} from './styles'; 10 | import {emmitEvent} from '../../api/helper'; 11 | 12 | const MyOverview = () => { 13 | const [isLoading, setIsLoading] = useState(true); 14 | const [courses, setCourses] = useState([]); 15 | 16 | useEffect(() => { 17 | Provider.getCourseWithCompletionStatus().then(data => { 18 | setCourses(data); 19 | setIsLoading(false); 20 | }); 21 | }, []); 22 | 23 | return ( 24 | 25 | 31 | 32 | {(isLoading && ( 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | )) || ( 67 | <> 68 | 'item-' + item.id} 74 | renderItem={({item, index}) => ( 75 | emmitEvent('core.course.view', {id: item.id})}> 77 | 85 | {(item.image && ( 86 | 92 | )) || ( 93 | 98 | 99 | 100 | )} 101 | 102 | {item.displayname} 103 | 108 | 109 | 110 | 111 | )} 112 | /> 113 | 114 | {courses.length === 0 && ( 115 | 122 | 123 | Você está matriculado em nenhum curso. 124 | 125 | )} 126 | 127 | )} 128 | 129 | 130 | ); 131 | }; 132 | 133 | export default MyOverview; 134 | -------------------------------------------------------------------------------- /src/blocks/myoverview/provider.js: -------------------------------------------------------------------------------- 1 | import { 2 | callMoodleWebService, 3 | getUserCourses, 4 | getCurrentUserDetails, 5 | } from '../../api/helper'; 6 | import Constants from '../../api/constants'; 7 | import AsyncStorage from '@react-native-community/async-storage'; 8 | import RNFetchBlob from 'rn-fetch-blob'; 9 | 10 | const getImage = async url => { 11 | if (typeof url !== 'undefined') { 12 | const token = await AsyncStorage.getItem(Constants.MOODLE_USER_TOKEN); 13 | const response = await RNFetchBlob.config({ 14 | fileCache: true, 15 | }).fetch('GET', url + '?token=' + token); 16 | return response.path(); 17 | } 18 | 19 | return null; 20 | }; 21 | 22 | export const getCourseWithCompletionStatus = async () => { 23 | const coursesWithExtraFields = []; 24 | const userCourses = await getUserCourses(); 25 | 26 | for (const course of userCourses) { 27 | let activities_completed = 0; 28 | const {userid} = await getCurrentUserDetails(); 29 | const {statuses} = await callMoodleWebService( 30 | 'core_completion_get_activities_completion_status', 31 | { 32 | userid: userid, 33 | courseid: course.id, 34 | }, 35 | ); 36 | 37 | const {courses} = await callMoodleWebService( 38 | 'core_course_get_courses_by_field', 39 | { 40 | field: 'id', 41 | value: course.id, 42 | }, 43 | ); 44 | 45 | courses[0].image = await getImage(courses[0].overviewfiles[0]?.fileurl); 46 | statuses.map(({state}) => state && activities_completed++); 47 | course.completion = statuses; 48 | course.percentage = (activities_completed / statuses.length) * 100; 49 | coursesWithExtraFields.push(Object.assign(course, courses[0])); 50 | } 51 | 52 | return coursesWithExtraFields; 53 | }; 54 | 55 | export default {getCourseWithCompletionStatus}; 56 | -------------------------------------------------------------------------------- /src/blocks/myoverview/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | courseContainer: { 5 | width: 300, 6 | }, 7 | courseImage: { 8 | height: 170, 9 | }, 10 | courseNoImage: { 11 | backgroundColor: '#cacaca', 12 | alignItems: 'center', 13 | justifyContent: 'center', 14 | }, 15 | courseFooter: { 16 | padding: 10, 17 | backgroundColor: '#f1f1f1', 18 | }, 19 | courseTitle: { 20 | fontSize: 16, 21 | }, 22 | marginVerticalDefault: { 23 | marginVertical: 15, 24 | }, 25 | marginHorizontalDefault: { 26 | marginHorizontal: 15, 27 | }, 28 | marginTopDefault: { 29 | marginTop: 15, 30 | }, 31 | marginBottomDefault: { 32 | marginBottom: 15, 33 | }, 34 | marginRightDefault: { 35 | marginRight: 15, 36 | }, 37 | marginLeftDefault: { 38 | marginLeft: 15, 39 | }, 40 | overflowHidden: { 41 | overflow: 'hidden', 42 | }, 43 | paddingVerticalDefault: { 44 | paddingVertical: 15, 45 | }, 46 | paddingHorizontalDefault: { 47 | paddingHorizontal: 15, 48 | }, 49 | alignItemsCenter: { 50 | alignItems: 'center', 51 | }, 52 | }); 53 | 54 | export default styles; 55 | -------------------------------------------------------------------------------- /src/blocks/notfound/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {styles} from './styles'; 3 | import {View} from 'react-native'; 4 | import {Card} from 'react-native-paper'; 5 | 6 | const Timeline = ({title}) => { 7 | return ( 8 | 9 | 14 | 15 | 16 | 17 | ); 18 | }; 19 | 20 | export default Timeline; 21 | -------------------------------------------------------------------------------- /src/blocks/notfound/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | }); 11 | 12 | export default styles; 13 | -------------------------------------------------------------------------------- /src/blocks/recentlyaccessedcourses/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {FlatList, View, Image, Text, TouchableOpacity} from 'react-native'; 3 | import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; 4 | import SkeletonPlaceholder from 'react-native-skeleton-placeholder'; 5 | import {Card} from 'react-native-paper'; 6 | 7 | import Provider from './provider'; 8 | import {styles} from './styles'; 9 | import {emmitEvent} from '../../api/helper'; 10 | import Locales from '../../locales'; 11 | 12 | const RecentlyAccessedCourses = () => { 13 | const [isLoading, setIsLoading] = useState(true); 14 | const [courses, setCourses] = useState([]); 15 | 16 | useEffect(() => { 17 | Provider.getRecentlyAccessedCourses().then(data => { 18 | setCourses(data); 19 | setIsLoading(false); 20 | }); 21 | }, []); 22 | 23 | return ( 24 | 25 | 31 | 32 | {(isLoading && ( 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | )) || ( 66 | <> 67 | 'item-' + item.id} 73 | renderItem={({item, index}) => ( 74 | emmitEvent('core.course.view', {id: item.id})}> 76 | 84 | {(item.image && ( 85 | 91 | )) || ( 92 | 97 | 98 | 99 | )} 100 | 101 | {item.displayname} 102 | 103 | 104 | 105 | )} 106 | /> 107 | 108 | {courses.length === 0 && ( 109 | 116 | 117 | Você não acessou nenhum curso recentemente 118 | 119 | )} 120 | 121 | )} 122 | 123 | 124 | ); 125 | }; 126 | 127 | export default RecentlyAccessedCourses; 128 | -------------------------------------------------------------------------------- /src/blocks/recentlyaccessedcourses/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService, getUserCourses} from '../../api/helper'; 2 | import Constants from '../../api/constants'; 3 | import AsyncStorage from '@react-native-community/async-storage'; 4 | import RNFetchBlob from 'rn-fetch-blob'; 5 | 6 | export const getImage = async url => { 7 | if (typeof url !== 'undefined') { 8 | const token = await AsyncStorage.getItem(Constants.MOODLE_USER_TOKEN); 9 | const response = await RNFetchBlob.config({ 10 | fileCache: true, 11 | }).fetch('GET', url + '?token=' + token); 12 | return response.path(); 13 | } 14 | 15 | return null; 16 | }; 17 | 18 | export const getRecentlyAccessedCourses = async () => { 19 | const coursesWithExtraFields = []; 20 | const courses = await getUserCourses(); 21 | 22 | for (const course of courses) { 23 | const {courses} = await callMoodleWebService( 24 | 'core_course_get_courses_by_field', 25 | { 26 | field: 'id', 27 | value: course.id, 28 | }, 29 | ); 30 | 31 | courses[0].image = await getImage(courses[0].overviewfiles[0]?.fileurl); 32 | 33 | coursesWithExtraFields.push(Object.assign(course, courses[0])); 34 | } 35 | 36 | coursesWithExtraFields.sort((a, b) => { 37 | if (a.lastaccess > b.lastaccess) { 38 | return -1; 39 | } else if (a.lastaccess < b.lastaccess) { 40 | return 1; 41 | } else { 42 | return 0; 43 | } 44 | }); 45 | 46 | return coursesWithExtraFields; 47 | }; 48 | 49 | export default {getImage, getRecentlyAccessedCourses}; 50 | -------------------------------------------------------------------------------- /src/blocks/recentlyaccessedcourses/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | courseContainer: { 5 | width: 300, 6 | }, 7 | courseImage: { 8 | height: 170, 9 | }, 10 | courseNoImage: { 11 | backgroundColor: '#cacaca', 12 | alignItems: 'center', 13 | justifyContent: 'center', 14 | }, 15 | courseFooter: { 16 | padding: 10, 17 | backgroundColor: '#f1f1f1', 18 | }, 19 | courseTitle: { 20 | fontSize: 16, 21 | }, 22 | marginVerticalDefault: { 23 | marginVertical: 15, 24 | }, 25 | marginHorizontalDefault: { 26 | marginHorizontal: 15, 27 | }, 28 | marginBottomDefault: { 29 | marginBottom: 15, 30 | }, 31 | marginRightDefault: { 32 | marginRight: 15, 33 | }, 34 | marginLeftDefault: { 35 | marginLeft: 15, 36 | }, 37 | overflowHidden: { 38 | overflow: 'hidden', 39 | }, 40 | paddingVerticalDefault: { 41 | paddingVertical: 15, 42 | }, 43 | paddingHorizontalDefault: { 44 | paddingHorizontal: 15, 45 | }, 46 | alignItemsCenter: { 47 | alignItems: 'center', 48 | }, 49 | }); 50 | 51 | export default styles; 52 | -------------------------------------------------------------------------------- /src/blocks/timeline/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {View, Text} from 'react-native'; 3 | import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; 4 | import {Card, Divider, Button} from 'react-native-paper'; 5 | import SkeletonPlaceholder from 'react-native-skeleton-placeholder'; 6 | 7 | import Provider from './provider'; 8 | import {styles} from './styles'; 9 | 10 | const Timeline = () => { 11 | const [isLoading, setIsLoading] = useState(true); 12 | const [events, setEvents] = useState([]); 13 | 14 | useEffect(() => { 15 | Provider.getActionsEventsByTimesort().then(data => 16 | setEvents(data.events.slice(0, 3)), 17 | ); 18 | setIsLoading(false); 19 | }, []); 20 | 21 | return ( 22 | 23 | 28 | 29 | 30 | {(isLoading && ( 31 | 32 | 33 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 55 | 60 | 61 | 62 | )) || ( 63 | <> 64 | {events.map(event => ( 65 | 66 | {event.name} 67 | 68 | {event.course.fullname} 69 | 70 | 71 | {new Date(event.timestart * 1000).toLocaleString('pt-BR')} 72 | 73 | 74 | 75 | ))} 76 | 77 | {events.length === 0 && ( 78 | 79 | 80 | Você não tem tarefas 81 | 82 | )} 83 | 84 | )} 85 | 86 | 87 | 90 | 91 | 92 | 93 | ); 94 | }; 95 | 96 | export default Timeline; 97 | -------------------------------------------------------------------------------- /src/blocks/timeline/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../api/helper'; 2 | 3 | export const getActionsEventsByTimesort = async () => { 4 | try { 5 | const response = await callMoodleWebService( 6 | 'core_calendar_get_action_events_by_timesort', 7 | ); 8 | 9 | return response; 10 | } catch (error) { 11 | console.error(error); 12 | } 13 | }; 14 | 15 | export default {getActionsEventsByTimesort}; 16 | -------------------------------------------------------------------------------- /src/blocks/timeline/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | eventTitle: { 5 | fontSize: 18, 6 | }, 7 | eventCourseTitle: { 8 | color: '#c6c6c6', 9 | }, 10 | eventContainer: { 11 | margin: 15, 12 | }, 13 | noEventsContainer: { 14 | padding: 15, 15 | alignItems: 'center', 16 | }, 17 | marginVerticalDefault: { 18 | marginVertical: 15, 19 | }, 20 | marginHorizontalDefault: { 21 | marginHorizontal: 15, 22 | }, 23 | marginTopDefault: { 24 | marginTop: 15, 25 | }, 26 | marginBottomDefault: { 27 | marginBottom: 15, 28 | }, 29 | justifyEnd: { 30 | justifyContent: 'flex-end', 31 | }, 32 | }); 33 | 34 | export default styles; 35 | -------------------------------------------------------------------------------- /src/components/Dialog/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Dialog as DialogPaper, Paragraph, Button} from 'react-native-paper'; 3 | 4 | const Dialog = ({visible, title, content, onDismiss, doneText}) => ( 5 | 6 | {title} 7 | 8 | {content} 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | 16 | export default Dialog; 17 | -------------------------------------------------------------------------------- /src/components/LoadingIndicator/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Modal, View} from 'react-native'; 3 | import {ActivityIndicator} from 'react-native-paper'; 4 | 5 | import {styles} from './styles'; 6 | 7 | const LoadingIndicator = ({hasActivity = false}) => ( 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ); 18 | 19 | export default LoadingIndicator; 20 | -------------------------------------------------------------------------------- /src/components/LoadingIndicator/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | flex: { 5 | flex: 1, 6 | }, 7 | center: { 8 | alignItems: 'center', 9 | justifyContent: 'center', 10 | }, 11 | container: { 12 | backgroundColor: '#00000040', 13 | }, 14 | activityWrapper: { 15 | width: 100, 16 | height: 100, 17 | borderRadius: 10, 18 | backgroundColor: '#fff', 19 | }, 20 | }); 21 | 22 | export default styles; 23 | -------------------------------------------------------------------------------- /src/components/Page/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View, ScrollView} from 'react-native'; 3 | import {Appbar} from 'react-native-paper'; 4 | import {styles} from './styles'; 5 | 6 | const Page = ({appbar, children, hasScrollView = true}) => { 7 | return ( 8 | 9 | 10 | {appbar?.canGoBack && } 11 | 12 | 16 | 17 | 18 | {(hasScrollView && ( 19 | 20 | {children} 21 | 22 | )) || <>{children}} 23 | 24 | ); 25 | }; 26 | 27 | export default Page; 28 | -------------------------------------------------------------------------------- /src/components/Page/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | flex: { 5 | flex: 1, 6 | }, 7 | flexGrow: { 8 | flexGrow: 1, 9 | }, 10 | }); 11 | 12 | export default styles; 13 | -------------------------------------------------------------------------------- /src/components/index.js: -------------------------------------------------------------------------------- 1 | export {default as Page} from './Page'; 2 | export {default as Dialog} from './Dialog'; 3 | export {default as LoadingIndicator} from './LoadingIndicator'; 4 | -------------------------------------------------------------------------------- /src/events/course.js: -------------------------------------------------------------------------------- 1 | import Navigation from '../RootNavigation'; 2 | import {callMoodleWebService} from '../api/helper'; 3 | 4 | const events = [ 5 | { 6 | name: 'core.course.view', 7 | handler: async ({id}) => { 8 | await callMoodleWebService('core_course_view_course', { 9 | courseid: id, 10 | }); 11 | console.log(`Event core.course.view received with id ${id}!`); 12 | Navigation.navigate('coursecontext', {screen: 'view', params: {id}}); 13 | }, 14 | }, 15 | { 16 | name: 'core.course.grade.view', 17 | handler: ({id}) => { 18 | console.log(`Event core.course.grade.view received with id ${id}`); 19 | Navigation.navigate('aboutsubcontext', { 20 | screen: 'gradesview', 21 | params: {id}, 22 | }); 23 | }, 24 | }, 25 | ]; 26 | 27 | export default events; 28 | -------------------------------------------------------------------------------- /src/events/index.js: -------------------------------------------------------------------------------- 1 | import course from './course'; 2 | import user from './user'; 3 | import module from './module'; 4 | 5 | export default [] 6 | .concat(course) 7 | .concat(user) 8 | .concat(module); 9 | -------------------------------------------------------------------------------- /src/events/module.js: -------------------------------------------------------------------------------- 1 | import Navigation from '../RootNavigation'; 2 | import {callMoodleWebService} from '../api/helper'; 3 | 4 | const events = [ 5 | { 6 | name: 'core.module.view', 7 | handler: async ({item, courseid}) => { 8 | console.log( 9 | `Event core.module.view received with name ${item.name} and modname ${ 10 | item.modname 11 | }`, 12 | ); 13 | switch (item.modname) { 14 | case 'page': 15 | await callMoodleWebService('mod_page_view_page', { 16 | pageid: item.instance, 17 | }); 18 | Navigation.navigate('modulescontext', { 19 | screen: 'page', 20 | params: {item, courseid}, 21 | }); 22 | break; 23 | case 'resource': 24 | await callMoodleWebService('mod_resource_view_resource ', { 25 | resourceid: item.instance, 26 | }); 27 | Navigation.navigate('modulescontext', { 28 | screen: 'resource', 29 | params: {item}, 30 | }); 31 | break; 32 | case 'feedback': 33 | await callMoodleWebService('mod_feedback_view_feedback', { 34 | feedbackid: item.instance, 35 | }); 36 | Navigation.navigate('modulescontext', { 37 | screen: 'feedback', 38 | params: {item, courseid}, 39 | }); 40 | break; 41 | default: 42 | Navigation.navigate('modulescontext', { 43 | screen: 'notfound', 44 | params: {item}, 45 | }); 46 | } 47 | }, 48 | }, 49 | ]; 50 | 51 | export default events; 52 | -------------------------------------------------------------------------------- /src/events/user.js: -------------------------------------------------------------------------------- 1 | import Navigation from '../RootNavigation'; 2 | import {callMoodleWebService} from '../api/helper'; 3 | 4 | const events = [ 5 | { 6 | name: 'core.user.view', 7 | handler: async ({id}) => { 8 | await callMoodleWebService('core_user_view_user_profile', { 9 | userid: id, 10 | }); 11 | console.log(`Event core.user.view received with id ${id}`); 12 | Navigation.navigate('aboutsubcontext', {screen: 'profile', params: {id}}); 13 | }, 14 | }, 15 | { 16 | name: 'core.user.details', 17 | handler: ({id}) => { 18 | console.log(`Event core.user.details received with id ${id}`); 19 | Navigation.navigate('aboutsubcontext', {screen: 'details', params: {id}}); 20 | }, 21 | }, 22 | { 23 | name: 'core.user.blogmessages', 24 | handler: ({id}) => { 25 | console.log(`Event core.user.blogmessages received with id ${id}`); 26 | Navigation.navigate('aboutsubcontext', { 27 | screen: 'blogmessages', 28 | params: {id}, 29 | }); 30 | }, 31 | }, 32 | { 33 | name: 'core.user.message.send', 34 | handler: ({id, touserid}) => { 35 | console.log('Event core.user.message.send received'); 36 | Navigation.navigate('messagessubcontext', { 37 | screen: 'view', 38 | params: {id, touserid}, 39 | }); 40 | }, 41 | }, 42 | ]; 43 | 44 | export default events; 45 | -------------------------------------------------------------------------------- /src/locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "about": "About", 3 | "profile": "Profile", 4 | "grades": "Grades", 5 | "signout": "Sign out", 6 | "message": "Message", 7 | "details": "Details", 8 | "blogposts": "Blog posts", 9 | "emblems": "Emblems", 10 | "messages": "Messages", 11 | "favorites": "Favorites", 12 | "group": "Group", 13 | "private": "Private", 14 | "settings": "Settings", 15 | "notificationpreferences": "Notification preferences", 16 | "email": "Email", 17 | "general": "General", 18 | "useentertosend": "Use enter to send", 19 | "dashboard": "Dashboard", 20 | "activities": "Activities", 21 | "participants": "Participants", 22 | "openexternalactivity": "Open external activity", 23 | "login": "Log in", 24 | "username": "Username", 25 | "password": "Password", 26 | "firstname": "First name", 27 | "lastname": "Last name", 28 | "createanewaccount": "Create a new account", 29 | "register": "Register", 30 | "recentlyaccessedcourses": "Recently accessed courses", 31 | "myoverview": "My overview" 32 | } -------------------------------------------------------------------------------- /src/locales/index.js: -------------------------------------------------------------------------------- 1 | import i18n from 'react-native-i18n'; 2 | import en from './en.json'; 3 | import pt_br from './pt-br.json'; 4 | 5 | i18n.fallbacks = true; 6 | i18n.translations = { 7 | en, 8 | 'pt-BR': pt_br, 9 | }; 10 | 11 | export default i18n; 12 | -------------------------------------------------------------------------------- /src/locales/pt-br.json: -------------------------------------------------------------------------------- 1 | { 2 | "about": "Sobre", 3 | "profile": "Perfil", 4 | "grades": "Notas", 5 | "signout": "Sair", 6 | "message": "Mensagem", 7 | "details": "Detalhes", 8 | "blogposts": "Mensagens do blog", 9 | "emblems": "Emblemas", 10 | "messages": "Mensagens", 11 | "favorites": "Favoritos", 12 | "group": "Grupo", 13 | "private": "Privado", 14 | "settings": "Configurações", 15 | "notificationpreferences": "Preferências de notificação", 16 | "email": "Email", 17 | "general": "Geral", 18 | "useentertosend": "Use enter para enviar", 19 | "dashboard": "Dashboard", 20 | "activities": "Atividades", 21 | "participants": "Participantes", 22 | "openexternalactivity": "Abrir atividade external", 23 | "login": "Entrar", 24 | "username": "Nome de usuário", 25 | "password": "Senha", 26 | "firstname": "Nome", 27 | "lastname": "Sobrenome", 28 | "createanewaccount": "Criar uma nova conta", 29 | "register": "Registro", 30 | "recentlyaccessedcourses": "Cursos acessados recentemente", 31 | "myoverview": "Resumo dos cursos" 32 | } -------------------------------------------------------------------------------- /src/modules/feedback/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {View} from 'react-native'; 3 | import {Button} from 'react-native-paper'; 4 | import RenderHTML from 'react-native-render-html'; 5 | 6 | import {styles} from './styles'; 7 | import Provider from './provider'; 8 | import {Page} from '../../components'; 9 | 10 | const Feedback = ({navigation, route}) => { 11 | const [feedback, setFeedback] = useState({}); 12 | 13 | useEffect(() => { 14 | const {item, courseid} = route.params; 15 | Provider.getFeedbackById({...item, courseid}).then(data => 16 | setFeedback(data), 17 | ); 18 | }, [route.params]); 19 | 20 | return ( 21 | 27 | 28 | {feedback?.intro && } 29 | 32 | 38 | 39 | 40 | ); 41 | }; 42 | 43 | export default Feedback; 44 | -------------------------------------------------------------------------------- /src/modules/feedback/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../api/helper'; 2 | 3 | export const Provider = { 4 | getFeedbackById: async module => { 5 | const {feedbacks} = await Helper.callMoodleWebService( 6 | 'mod_feedback_get_feedbacks_by_courses', 7 | { 8 | courseids: [module.courseid], 9 | }, 10 | ); 11 | const feedback = feedbacks.find( 12 | _feedback => _feedback.coursemodule === module.id, 13 | ); 14 | return feedback; 15 | }, 16 | }; 17 | 18 | export default Provider; 19 | -------------------------------------------------------------------------------- /src/modules/feedback/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginHorizontalDefault: { 5 | marginHorizontal: 15, 6 | }, 7 | marginVerticalDefault: { 8 | marginVertical: 15, 9 | }, 10 | }); 11 | 12 | export default styles; 13 | -------------------------------------------------------------------------------- /src/modules/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {createStackNavigator} from '@react-navigation/stack'; 3 | 4 | import Page from './page'; 5 | import NotFound from './notfound'; 6 | import Resource from './resource'; 7 | import Feedback from './feedback'; 8 | 9 | const Modules = () => { 10 | const Stack = createStackNavigator(); 11 | 12 | return ( 13 | 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | }; 21 | 22 | export default Modules; 23 | -------------------------------------------------------------------------------- /src/modules/notfound/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View} from 'react-native'; 3 | import {Button, Title, Paragraph} from 'react-native-paper'; 4 | import InAppBrowser from 'react-native-inappbrowser-reborn'; 5 | 6 | import {styles} from './styles'; 7 | import {Page} from '../../components'; 8 | 9 | const NotFound = ({navigation, route}) => { 10 | const params = route.params.item; 11 | 12 | const openInBrowser = async ({url}) => { 13 | await InAppBrowser.open(url); 14 | }; 15 | 16 | return ( 17 | 23 | 28 | Uh, oh! 29 | 30 | Sua organização instalou um plugin que não é suportado ainda. 31 | 32 | 33 | Contate o administrador do site e diga que você deseja usar essa 34 | atividade no aplicativo Moodle Mobile. 35 | 36 | 37 | Você ainda pode usar isso no navegador do seu dispositivo 38 | 39 | 47 | 48 | 49 | ); 50 | }; 51 | 52 | export default NotFound; 53 | -------------------------------------------------------------------------------- /src/modules/notfound/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | bold: { 11 | fontWeight: 'bold', 12 | }, 13 | button: {}, 14 | }); 15 | 16 | export default styles; 17 | -------------------------------------------------------------------------------- /src/modules/page/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {View} from 'react-native'; 3 | import RenderHTML from 'react-native-render-html'; 4 | 5 | import {styles} from './styles'; 6 | import Provider from './provider'; 7 | import {Page as RNPage} from '../../components'; 8 | 9 | const Page = ({navigation, route}) => { 10 | const [title, setTitle] = useState(''); 11 | const [page, setPage] = useState(null); 12 | 13 | useEffect(() => { 14 | setTitle(route?.params?.item.name); 15 | Provider.getPage(route?.params?.item, route?.params?.courseid).then(data => 16 | setPage(data.content), 17 | ); 18 | }, [route]); 19 | 20 | return ( 21 | 27 | 32 | {page !== null && ( 33 | { 36 | if (node.name === 'iframe') { 37 | delete node.attribs.width; 38 | delete node.attribs.height; 39 | } 40 | return node.children; 41 | }} 42 | /> 43 | )} 44 | 45 | 46 | ); 47 | }; 48 | 49 | export default Page; 50 | -------------------------------------------------------------------------------- /src/modules/page/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../api/helper'; 2 | 3 | export const Provider = { 4 | getPage: async ({id}, courseid) => { 5 | const {pages} = await callMoodleWebService( 6 | 'mod_page_get_pages_by_courses', 7 | { 8 | courseids: [courseid], 9 | }, 10 | ); 11 | const page = pages.find(value => value.coursemodule === id); 12 | return page; 13 | }, 14 | }; 15 | 16 | export default Provider; 17 | -------------------------------------------------------------------------------- /src/modules/page/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | }); 11 | 12 | export default styles; 13 | -------------------------------------------------------------------------------- /src/modules/resource/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import Provider from './provider'; 3 | import {View, Text} from 'react-native'; 4 | import RenderHTML from 'react-native-render-html'; 5 | import {Button} from 'react-native-paper'; 6 | import Share from 'react-native-share'; 7 | 8 | import {Page} from '../../components'; 9 | 10 | export const Resource = ({navigation, route}) => { 11 | const [resource, setResource] = useState({}); 12 | 13 | useEffect(() => { 14 | const {instance} = route?.params?.item; 15 | Provider.getResourceDataByKey({instance}).then(data => { 16 | setResource(data); 17 | }); 18 | }, [route]); 19 | 20 | const openFile = ({fileurl, filename}) => { 21 | (async () => { 22 | const {data} = await Provider.downloadFile({fileurl, filename}); 23 | await Share.open({url: data}); 24 | })(); 25 | }; 26 | 27 | return ( 28 | 34 | 35 | 36 | 37 | 38 | {resource?.contentfiles?.map(file => ( 39 | <> 40 | Arquivo: {file.filename} 41 | 42 | 43 | ))} 44 | 45 | 46 | ); 47 | }; 48 | 49 | export default Resource; 50 | -------------------------------------------------------------------------------- /src/modules/resource/provider.js: -------------------------------------------------------------------------------- 1 | import RNFetchBlob from 'rn-fetch-blob'; 2 | import Helper from '../../api/helper'; 3 | 4 | export const getResourceDataByKey = async ({instance}) => { 5 | const response = await Helper.callMoodleWebService( 6 | 'mod_resource_get_resources_by_courses', 7 | ); 8 | const resources = response.resources; 9 | const resource = resources.find(({id}) => id === instance); 10 | return resource; 11 | }; 12 | 13 | export const downloadFile = async ({fileurl, filename}) => { 14 | const token = await Helper.getMoodleUserToken(); 15 | const file = await RNFetchBlob.config({ 16 | fileCache: true, 17 | path: RNFetchBlob.fs.dirs.CacheDir + '/' + filename, 18 | }).fetch('GET', fileurl + '?token=' + token); 19 | return file; 20 | }; 21 | 22 | export default {getResourceDataByKey, downloadFile}; 23 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Login/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {View} from 'react-native'; 3 | import {useTheme} from 'react-native-paper'; 4 | 5 | import {styles} from './styles'; 6 | import Provider from './provider'; 7 | import Locales from '../../../locales'; 8 | import {TextInput, Button} from 'react-native-paper'; 9 | import {Page, LoadingIndicator, Dialog} from '../../../components'; 10 | 11 | const Login = ({navigation}) => { 12 | const [hasError, setHasError] = useState(null); 13 | const [isLoading, setIsLoading] = useState(false); 14 | 15 | const [username, setUsername] = useState(''); 16 | const [password, setPassword] = useState(''); 17 | const [identityProviders, setIdentityProviders] = useState([]); 18 | const Theme = useTheme(); 19 | 20 | useEffect(() => { 21 | (async () => { 22 | try { 23 | const data = await Provider.getIdentityProviders(); 24 | setIdentityProviders(data); 25 | } catch (error) { 26 | console.error(error); 27 | setHasError(error); 28 | } 29 | })(); 30 | }, []); 31 | 32 | const performLogin = async () => { 33 | try { 34 | setIsLoading(true); 35 | await Provider.makeLogin({navigation, username, password}); 36 | } catch (error) { 37 | console.error(error); 38 | setHasError(error); 39 | } finally { 40 | setIsLoading(false); 41 | } 42 | }; 43 | 44 | return ( 45 | <> 46 | 47 | 52 | setUsername(text)} 58 | /> 59 | 60 | setPassword(text)} 66 | /> 67 | 68 | 74 | 75 | {identityProviders?.map(provider => ( 76 | 96 | ))} 97 | 98 | 104 | 105 | 106 | 107 | 108 | 109 | {hasError && ( 110 |

{ 116 | setHasError(null); 117 | }} 118 | /> 119 | )} 120 | 121 | ); 122 | }; 123 | 124 | export default Login; 125 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Login/provider.js: -------------------------------------------------------------------------------- 1 | import {Linking} from 'react-native'; 2 | import Provider from '../../../api/helper'; 3 | import Constants from '../../../api/constants'; 4 | import InAppBrowser from 'react-native-inappbrowser-reborn'; 5 | 6 | const splitUrl = (url = '') => { 7 | const result = { 8 | protocol: '', 9 | domain: '', 10 | routes: [], 11 | params: {}, 12 | }; 13 | const tokens = url.split('/'); 14 | let head = 0; 15 | if (tokens[1] === '') { 16 | head = 2; 17 | result.protocol = tokens[0].substr(0, tokens[0].length - 1); 18 | } 19 | result.domain = tokens[head]; 20 | 21 | for (let i = head + 1; i < tokens.length - 1; i++) { 22 | result.routes.push(tokens[i]); 23 | } 24 | 25 | const page = tokens[tokens.length - 1].split('?'); 26 | result.routes.push(page[0]); 27 | const query = page[1]; 28 | const params = query.split('&'); 29 | 30 | for (let param of params) { 31 | param = param.split('='); 32 | result.params[param[0]] = param[1]; 33 | } 34 | 35 | return result; 36 | }; 37 | 38 | export const openBrowserForOAuthLogin = async ({url, navigation}) => { 39 | let launchUrl = Constants.MOODLE_HOST + '/admin/tool/mobile/launch.php'; 40 | const uri = splitUrl(url); 41 | const options = { 42 | service: Constants.MOODLE_SERVICE, 43 | oauthsso: uri.params.id, 44 | passport: Math.random() * 1000, 45 | urlscheme: Constants.MOODLE_CUSTOMURLSCHEME, 46 | }; 47 | 48 | let index = 0; 49 | for (const [key, value] of Object.entries(options)) { 50 | if (index === 0) { 51 | launchUrl += '?'; 52 | } else { 53 | launchUrl += '&'; 54 | } 55 | launchUrl += `${key}=${value}`; 56 | index++; 57 | } 58 | 59 | if (await InAppBrowser.isAvailable()) { 60 | const result = await InAppBrowser.openAuth(launchUrl, null, { 61 | ephemeralWebSession: false, 62 | }); 63 | if (result.type === 'success') { 64 | const matches = /token=(.*)/.exec(result.url); 65 | const token = await Provider.setMoodleUserToken(matches[1]); 66 | console.log('result'); 67 | console.log(result.url); 68 | console.log('Token:'); 69 | console.log(token); 70 | // navigation.navigate('dashboardcontext', {screen: 'frontpage'}); 71 | } 72 | } else if (await Linking.canOpenURL(launchUrl)) { 73 | await Linking.openURL(launchUrl); 74 | } else { 75 | console.error('Cannot open identity provider'); 76 | } 77 | }; 78 | 79 | export const getIdentityProviders = async () => { 80 | const {identityproviders} = await Provider.callMoodleWebService( 81 | 'tool_mobile_get_public_config', 82 | { 83 | wstoken: Constants.MOODLE_ADMIN_TOKEN, 84 | }, 85 | ); 86 | return identityproviders; 87 | }; 88 | 89 | export const makeLogin = async ({navigation, username, password}) => { 90 | await Provider.renewMoodleUserToken({username: username, password}); 91 | navigation.navigate('dashboardcontext', {screen: 'frontpage'}); 92 | }; 93 | 94 | export default {openBrowserForOAuthLogin, getIdentityProviders, makeLogin}; 95 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Login/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | marginTopDefault: { 11 | marginTop: 15, 12 | }, 13 | }); 14 | 15 | export default styles; 16 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Register/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect, createRef} from 'react'; 2 | import {View} from 'react-native'; 3 | import {TextInput, Button} from 'react-native-paper'; 4 | 5 | import {styles} from './styles'; 6 | import Provider from './provider'; 7 | import Locales from '../../../locales'; 8 | import {Page, LoadingIndicator, Dialog} from '../../../components'; 9 | 10 | const Register = ({navigation}) => { 11 | const [fields, setFields] = useState([]); 12 | const [error, setError] = useState(null); 13 | const [isLoading, setIsLoading] = useState(false); 14 | 15 | useEffect(() => { 16 | setFields([ 17 | { 18 | stringid: 'username', 19 | placeholder: Locales.t('username'), 20 | ref: createRef(), 21 | autoCapitalize: 'none', 22 | }, 23 | { 24 | stringid: 'email', 25 | placeholder: Locales.t('email'), 26 | ref: createRef(), 27 | autoCapitalize: 'none', 28 | }, 29 | { 30 | stringid: 'password', 31 | placeholder: Locales.t('password'), 32 | ref: createRef(), 33 | autoCapitalize: 'none', 34 | secureTextEntry: true, 35 | }, 36 | { 37 | stringid: 'firstname', 38 | placeholder: Locales.t('firstname'), 39 | ref: createRef(), 40 | autoCapitalize: 'words', 41 | }, 42 | { 43 | stringid: 'lastname', 44 | placeholder: Locales.t('lastname'), 45 | ref: createRef(), 46 | autoCapitalize: 'words', 47 | }, 48 | ]); 49 | }, []); 50 | 51 | const performRegister = async () => { 52 | try { 53 | setIsLoading(true); 54 | const values = {}; 55 | fields.map(value => { 56 | values[value.stringid] = value.ref.current.state.value || ''; 57 | }); 58 | await Provider.registerUser(values); 59 | navigation.pop(); 60 | } catch (exception) { 61 | let message = ''; 62 | console.log(exception); 63 | for (const warning of exception.warnings) { 64 | message += `${warning.message}\n`; 65 | } 66 | setError(message); 67 | } finally { 68 | setIsLoading(false); 69 | } 70 | }; 71 | 72 | return ( 73 | <> 74 | 80 | 84 | {fields.map( 85 | ({ 86 | stringid, 87 | placeholder, 88 | ref, 89 | autoCapitalize, 90 | secureTextEntry = false, 91 | }) => { 92 | return ( 93 | 104 | ); 105 | }, 106 | )} 107 | 108 | 116 | 117 | 118 | 119 | 120 | {error !== null && ( 121 | { 127 | setError(null); 128 | }} 129 | /> 130 | )} 131 | 132 | ); 133 | }; 134 | 135 | export default Register; 136 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Register/provider.js: -------------------------------------------------------------------------------- 1 | import Constants from '../../../api/constants'; 2 | 3 | const registerUser = async values => { 4 | const url = `${Constants.MOODLE_HOST}/lib/ajax/service.php`; 5 | const body = [ 6 | { 7 | index: '0', 8 | methodname: 'auth_email_signup_user', 9 | args: { 10 | ...values, 11 | }, 12 | }, 13 | ]; 14 | 15 | const response = await fetch(url, { 16 | method: 'POST', 17 | body: JSON.stringify(body), 18 | }); 19 | 20 | const {data} = (await response.json())[0]; 21 | 22 | if (!data.success) { 23 | throw data; 24 | } 25 | 26 | return data; 27 | }; 28 | 29 | export default {registerUser}; 30 | -------------------------------------------------------------------------------- /src/screens/AuthContext/Register/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | marginTopDefault: { 11 | marginTop: 15, 12 | }, 13 | }); 14 | 15 | export default styles; 16 | -------------------------------------------------------------------------------- /src/screens/AuthContext/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {createStackNavigator} from '@react-navigation/stack'; 3 | import Login from './Login'; 4 | import Register from './Register'; 5 | 6 | const AuthContext = () => { 7 | const Stack = createStackNavigator(); 8 | 9 | return ( 10 | 11 | 12 | 13 | 14 | ); 15 | }; 16 | 17 | export default AuthContext; 18 | -------------------------------------------------------------------------------- /src/screens/ContextManager.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect} from 'react'; 2 | import AsyncStorage from '@react-native-community/async-storage'; 3 | import Constants from '../api/constants'; 4 | import {updateCurrentUserDetails} from '../api/helper'; 5 | 6 | const SplashScreen = ({navigation}) => { 7 | const verifyLogin = async () => { 8 | const token = await AsyncStorage.getItem(Constants.MOODLE_USER_TOKEN); 9 | if (!token) { 10 | navigation.replace('authcontext'); 11 | } else { 12 | await updateCurrentUserDetails(); 13 | navigation.replace('dashboardcontext'); 14 | } 15 | }; 16 | 17 | useEffect(() => { 18 | verifyLogin(); 19 | }); 20 | 21 | return <>; 22 | }; 23 | 24 | export default SplashScreen; 25 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Activities/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {SafeAreaView, View, Text, ScrollView, Image} from 'react-native'; 3 | import Accordion from 'react-native-collapsible/Accordion'; 4 | import {Card, IconButton} from 'react-native-paper'; 5 | import {TouchableOpacity} from 'react-native-gesture-handler'; 6 | import SkeletonPlaceholder from 'react-native-skeleton-placeholder'; 7 | 8 | import {emmitEvent} from '../../../../api/helper'; 9 | import Provider from './provider'; 10 | import {styles} from './styles'; 11 | 12 | const Activities = ({route}) => { 13 | const [isLoading, setIsLoading] = useState(true); 14 | const [sections, setSections] = useState([]); 15 | const [activeSections, setActiveSections] = useState([0]); 16 | 17 | useEffect(() => { 18 | Provider.getSectionAndActivities(route.params.id).then(data => { 19 | setSections(data); 20 | setIsLoading(false); 21 | }); 22 | }, [route.params.id]); 23 | 24 | const _renderHeader = (section, index, isActive) => { 25 | return ( 26 | 32 | 35 | isActive ? ( 36 | {}} 40 | /> 41 | ) : ( 42 | {}} 46 | /> 47 | ) 48 | } 49 | /> 50 | 51 | ); 52 | }; 53 | 54 | const _renderActivity = ({item}) => { 55 | return ( 56 | { 59 | emmitEvent('core.module.view', {item, courseid: route.params.id}); 60 | }}> 61 | 66 | {item.modicontype !== 'image/svg+xml' && ( 67 | 74 | )} 75 | 80 | {item.name} 81 | 82 | 88 | 89 | 90 | ); 91 | }; 92 | 93 | const _renderContent = (section, index, isActive) => { 94 | return ( 95 | 100 | {sections[index].modules.map(module => ( 101 | <_renderActivity key={module.id} item={module} /> 102 | ))} 103 | 104 | ); 105 | }; 106 | 107 | const _updateSections = actives => { 108 | setActiveSections(actives); 109 | }; 110 | 111 | if (isLoading) { 112 | return ( 113 | 114 | 119 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 137 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 153 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 169 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | ); 181 | } 182 | 183 | return ( 184 | 185 | 186 | 187 | <>} 191 | renderHeader={_renderHeader} 192 | renderContent={_renderContent} 193 | onChange={_updateSections} 194 | touchableComponent={props => } 195 | /> 196 | 197 | 198 | 199 | ); 200 | }; 201 | 202 | export default Activities; 203 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Activities/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../../../api/helper'; 2 | 3 | export const getSectionAndActivities = async courseid => { 4 | const response = await callMoodleWebService('core_course_get_contents', { 5 | courseid, 6 | }); 7 | 8 | for (const section of response) { 9 | for (const module of section.modules) { 10 | const modicon = await fetch(module.modicon); 11 | const {type} = await modicon.blob(); 12 | module.modicontype = type; 13 | } 14 | } 15 | 16 | return response; 17 | }; 18 | 19 | export default {getSectionAndActivities}; 20 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Activities/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | cardHeader: { 5 | borderBottomStartRadius: 0, 6 | borderBottomEndRadius: 0, 7 | }, 8 | cardContent: { 9 | borderTopStartRadius: 0, 10 | borderTopEndRadius: 0, 11 | }, 12 | flex: { 13 | flex: 1, 14 | }, 15 | flexGrow: { 16 | flexGrow: 1, 17 | }, 18 | rowDirection: { 19 | flexDirection: 'row', 20 | }, 21 | marginTop: { 22 | marginTop: 15, 23 | }, 24 | marginBottom: { 25 | marginBottom: 15, 26 | }, 27 | marginLeft: { 28 | marginLeft: 15, 29 | }, 30 | marginRight: { 31 | marginRight: 15, 32 | }, 33 | marginVertical: { 34 | marginVertical: 15, 35 | }, 36 | marginHorizontal: { 37 | marginHorizontal: 15, 38 | }, 39 | alignCenter: { 40 | alignItems: 'center', 41 | }, 42 | modIcon: { 43 | width: 25, 44 | height: 25, 45 | }, 46 | }); 47 | 48 | export default styles; 49 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Participants/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import { 3 | SafeAreaView, 4 | View, 5 | ScrollView, 6 | Text, 7 | Image, 8 | TouchableOpacity, 9 | } from 'react-native'; 10 | import {Card, Divider} from 'react-native-paper'; 11 | import Provider from './provider'; 12 | import {styles} from './styles'; 13 | import {emmitEvent} from '../../../../api/helper'; 14 | import SkeletonPlaceholder from 'react-native-skeleton-placeholder'; 15 | import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; 16 | 17 | const Participants = ({route}) => { 18 | const [isLoading, setIsLoading] = useState(true); 19 | const [participants, setParticipants] = useState([]); 20 | 21 | useEffect(() => { 22 | Provider.getParticipants(route.params.id).then(data => { 23 | setParticipants(data); 24 | setIsLoading(false); 25 | }); 26 | }, [route.params.id]); 27 | 28 | return ( 29 | 30 | 31 | 37 | {(isLoading && ( 38 | 39 | 43 | 44 | 48 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 63 | 64 | 65 | 66 | 67 | 68 | 73 | 74 | 78 | 79 | 80 | 81 | 82 | 83 | )) || 84 | participants.map((item, index) => ( 85 | 86 | { 88 | emmitEvent('core.user.view', {id: item.id}); 89 | }}> 90 | 91 | 98 | 103 | 107 | 108 | {item.fullname} 109 | {item.lastaccesstime && ( 110 | Último acesso: {item.lastaccesstime} 111 | )} 112 | 113 | 114 | 115 | 116 | 117 | 118 | {index !== participants.length - 1 && } 119 | 120 | ))} 121 | 122 | 123 | 124 | ); 125 | }; 126 | 127 | export default Participants; 128 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Participants/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../../../api/helper'; 2 | import i18n from 'react-native-i18n'; 3 | import Moment from 'moment'; 4 | import 'moment/locale/pt-br'; 5 | 6 | export const getParticipants = async courseid => { 7 | const locale = i18n.currentLocale(); 8 | Moment.locale(locale); 9 | const response = await callMoodleWebService('core_enrol_get_enrolled_users', { 10 | courseid, 11 | }); 12 | for (const participant of response) { 13 | if (participant.lastaccess !== 0) { 14 | const lastaccess = Moment(new Date(participant.lastaccess * 1000)); 15 | const currentdate = Moment(); 16 | const difference = currentdate.diff(lastaccess); 17 | const duration = Moment.duration(difference); 18 | participant.lastaccesstime = duration.humanize(); 19 | } 20 | } 21 | 22 | return response; 23 | }; 24 | 25 | export default {getParticipants}; 26 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/Participants/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginHorizontalDefault: { 5 | marginHorizontal: 15, 6 | }, 7 | marginTopDefault: { 8 | marginTop: 15, 9 | }, 10 | marginBottomDefault: { 11 | marginBottom: 15, 12 | }, 13 | marginLeftDefault: { 14 | marginLeft: 15, 15 | }, 16 | paddingDefault: { 17 | padding: 15, 18 | }, 19 | row: { 20 | flexDirection: 'row', 21 | }, 22 | alignCenter: { 23 | alignItems: 'center', 24 | }, 25 | userImage: { 26 | width: 50, 27 | height: 50, 28 | }, 29 | spaceBetween: { 30 | justifyContent: 'space-between', 31 | }, 32 | }); 33 | 34 | export default styles; 35 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Appbar} from 'react-native-paper'; 3 | import { 4 | createMaterialTopTabNavigator, 5 | MaterialTopTabBar, 6 | } from '@react-navigation/material-top-tabs'; 7 | import Provider from './provider'; 8 | import Activities from './Activities'; 9 | import Participants from './Participants'; 10 | import {useTheme} from 'react-native-paper'; 11 | import Locales from '../../../locales'; 12 | 13 | const Course = ({navigation, route}) => { 14 | const [course, setCourse] = useState({ 15 | displayname: 'Curso', 16 | }); 17 | const Tab = createMaterialTopTabNavigator(); 18 | const Theme = useTheme(); 19 | 20 | useEffect(() => { 21 | Provider.getCourseDetail(route.params.id).then(data => setCourse(data)); 22 | }, [route.params.id]); 23 | 24 | return ( 25 | ( 27 | <> 28 | 29 | 30 | 31 | 32 | 39 | 40 | )} 41 | headerMode="none" 42 | initialRouteName="view"> 43 | 48 | 53 | 54 | ); 55 | }; 56 | 57 | export default Course; 58 | -------------------------------------------------------------------------------- /src/screens/CourseContext/View/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../../api/helper'; 2 | 3 | export const getCourseDetail = async id => { 4 | const {courses} = await callMoodleWebService( 5 | 'core_course_get_courses_by_field', 6 | { 7 | field: 'id', 8 | value: id, 9 | }, 10 | ); 11 | return courses[0]; 12 | }; 13 | 14 | export default {getCourseDetail}; 15 | -------------------------------------------------------------------------------- /src/screens/CourseContext/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {createStackNavigator} from '@react-navigation/stack'; 3 | 4 | import View from './View'; 5 | 6 | const CourseContext = () => { 7 | const Stack = createStackNavigator(); 8 | 9 | return ( 10 | 11 | 12 | 13 | ); 14 | }; 15 | 16 | export default CourseContext; 17 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/About/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {View, Image} from 'react-native'; 3 | import {Card, List, Divider} from 'react-native-paper'; 4 | 5 | import Locales from '../../../locales'; 6 | import {styles} from './styles'; 7 | import {Page} from '../../../components'; 8 | import {getCurrentUserDetails} from '../../../api/helper'; 9 | import {emmitEvent} from '../../../api/helper'; 10 | import Provider from './provider'; 11 | 12 | const About = ({navigation}) => { 13 | const [user, setUser] = useState(null); 14 | 15 | useEffect(() => { 16 | getCurrentUserDetails().then(data => setUser(data)); 17 | }, []); 18 | 19 | return ( 20 | 21 | 26 | 27 | 28 | {Locales.t('profile')} 29 | ( 33 | 37 | )} 38 | onPress={() => { 39 | emmitEvent('core.user.view', {id: user?.userid}); 40 | }} 41 | /> 42 | 43 | 44 | 45 | 46 | 47 | } 50 | onPress={() => { 51 | navigation.navigate('aboutsubcontext', { 52 | screen: 'grades', 53 | }); 54 | }} 55 | /> 56 | } 59 | onPress={() => Provider.performLogout(navigation)} 60 | /> 61 | 62 | 63 | 64 | 65 | ); 66 | }; 67 | 68 | export default About; 69 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/About/provider.js: -------------------------------------------------------------------------------- 1 | import AsyncStorage from '@react-native-community/async-storage'; 2 | import Constants from '../../../api/constants'; 3 | 4 | export const performLogout = async navigation => { 5 | await AsyncStorage.removeItem(Constants.MOODLE_USER_TOKEN); 6 | navigation.replace('contextmanager'); 7 | }; 8 | 9 | export default {performLogout}; 10 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/About/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | centerItems: { 11 | alignItems: 'center', 12 | }, 13 | profileImage: { 14 | width: 50, 15 | height: 50, 16 | borderRadius: 25, 17 | }, 18 | }); 19 | 20 | export default styles; 21 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/BlogMessages/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Page} from '../../../../components'; 3 | import Provider from './provider'; 4 | import {View, TouchableOpacity} from 'react-native'; 5 | import {Card, Avatar} from 'react-native-paper'; 6 | import {styles} from './styles'; 7 | 8 | const BlogMessages = ({navigation, route}) => { 9 | const [entries, setEntries] = useState([]); 10 | 11 | useEffect(() => { 12 | Provider.getEntries({id: 221}).then(data => setEntries(data)); 13 | }, [route.params.id]); 14 | 15 | return ( 16 | 22 | 23 | {entries.map((entry, index) => { 24 | return ( 25 | {}}> 26 | 31 | 32 | ( 35 | 39 | )} 40 | subtitle={entry.user.fullname} 41 | /> 42 | 43 | 44 | 45 | ); 46 | })} 47 | 48 | 49 | ); 50 | }; 51 | 52 | export default BlogMessages; 53 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/BlogMessages/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../../../api/helper'; 2 | 3 | const getEntries = async ({id}) => { 4 | const {entries} = await Helper.callMoodleWebService('core_blog_get_entries', { 5 | filters: [ 6 | { 7 | name: 'userid', 8 | value: id, 9 | }, 10 | ], 11 | }); 12 | 13 | for (const entry of entries) { 14 | const user = await getUserDetail(entry.userid); 15 | entry.user = user; 16 | } 17 | 18 | return entries; 19 | }; 20 | 21 | const getUserDetail = async userid => { 22 | const response = await Helper.callMoodleWebService( 23 | 'core_user_get_users_by_field', 24 | { 25 | field: 'id', 26 | values: [userid], 27 | }, 28 | ); 29 | return response[0]; 30 | }; 31 | 32 | export default {getEntries}; 33 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/BlogMessages/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginHorizontalDefault: { 5 | marginHorizontal: 15, 6 | }, 7 | marginTopDefault: { 8 | marginTop: 15, 9 | }, 10 | }); 11 | 12 | export default styles; 13 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Details/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Page} from '../../../../components'; 3 | import {View} from 'react-native'; 4 | import {List} from 'react-native-paper'; 5 | import Provider from './provider'; 6 | import Locales from '../../../../locales'; 7 | 8 | const Details = ({navigation, route}) => { 9 | const [user, setUser] = useState({}); 10 | 11 | useEffect(() => { 12 | Provider.getUserDetails(route.params.id).then(data => setUser(data)); 13 | }, [route.params.id]); 14 | 15 | return ( 16 | 22 | 23 | 24 | Contato 25 | 26 | 27 | 28 | 29 | Detalhes do usuário 30 | {user?.customfields?.map((field, index) => { 31 | let description = ''; 32 | if (field.type === 'checkbox') { 33 | if (field.value === '1') { 34 | description = 'Sim'; 35 | } else { 36 | description = 'Não'; 37 | } 38 | } else if (field.type === 'datetime') { 39 | // TODO: Show date as string 40 | } else if (field.type === 'text') { 41 | description = field.value; 42 | } 43 | return ( 44 | 49 | ); 50 | })} 51 | 52 | 53 | 54 | ); 55 | }; 56 | 57 | export default Details; 58 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Details/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../../../api/helper'; 2 | 3 | const getUserDetails = async id => { 4 | const response = await Helper.callMoodleWebService( 5 | 'core_user_get_users_by_field', 6 | { 7 | field: 'id', 8 | values: [id], 9 | }, 10 | ); 11 | 12 | const user = response[0]; 13 | return user; 14 | }; 15 | 16 | export default {getUserDetails}; 17 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Grades/View/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Page} from '../../../../../components'; 3 | import {View, Text} from 'react-native'; 4 | 5 | const ViewGrade = ({navigation}) => { 6 | return ( 7 | 13 | 14 | View Grade 15 | 16 | 17 | ); 18 | }; 19 | 20 | export default ViewGrade; 21 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Grades/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {emmitEvent} from '../../../../api/helper'; 3 | import {View, Text, TouchableOpacity} from 'react-native'; 4 | import {Card} from 'react-native-paper'; 5 | 6 | import {Page} from '../../../../components'; 7 | import Provider from './provider'; 8 | import {styles} from './styles'; 9 | import Locales from '../../../../locales'; 10 | 11 | const Grades = ({navigation}) => { 12 | const [grades, setGrades] = useState([]); 13 | 14 | useEffect(() => { 15 | Provider.getGrades().then(data => setGrades(data)); 16 | }, []); 17 | 18 | return ( 19 | 25 | 26 | {grades.map(({course, courseid, totalgrade}, index) => ( 27 | 30 | emmitEvent('core.course.grade.view', {id: courseid}) 31 | }> 32 | 39 | 41 | {course} 42 | 43 | 44 | {totalgrade} 45 | 46 | 47 | 48 | 49 | ))} 50 | 51 | 52 | ); 53 | }; 54 | 55 | export default Grades; 56 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Grades/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../../../api/helper'; 2 | 3 | const getGrades = async () => { 4 | const {userid} = await Helper.getCurrentUserDetails(); 5 | const courses = await Helper.getUserCourses(); 6 | 7 | const grades = []; 8 | for (const course of courses) { 9 | const grade = { 10 | courseid: course.id, 11 | course: course.fullname, 12 | totalgrade: 0, 13 | }; 14 | 15 | const {usergrades} = await Helper.callMoodleWebService( 16 | 'gradereport_user_get_grade_items', 17 | { 18 | userid, 19 | courseid: course.id, 20 | }, 21 | ); 22 | 23 | const response = usergrades[0]; 24 | for (const item of response.gradeitems) { 25 | if (item.weightraw) { 26 | grade.totalgrade += item.graderaw * item.weightraw; 27 | } else if (item.gradedatesubmitted) { 28 | grade.totalgrade += item.graderaw; 29 | } 30 | } 31 | 32 | grades.push(grade); 33 | } 34 | 35 | return grades; 36 | }; 37 | 38 | export default {getGrades}; 39 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Grades/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | rowDirection: { 5 | alignItems: 'center', 6 | flexDirection: 'row', 7 | }, 8 | marginHorizontalDefault: { 9 | marginHorizontal: 15, 10 | }, 11 | marginTopDefault: { 12 | marginTop: 15, 13 | }, 14 | marginBottomDefault: { 15 | marginBottom: 15, 16 | }, 17 | paddingHorizontalDefault: { 18 | paddingHorizontal: 15, 19 | }, 20 | paddingVerticalDefault: { 21 | paddingVertical: 15, 22 | }, 23 | paddingLeftDefault: { 24 | paddingLeft: 15, 25 | }, 26 | gradeTitleStyle: {}, 27 | gradeTextStyle: { 28 | backgroundColor: '#373737', 29 | paddingVertical: 5, 30 | paddingHorizontal: 10, 31 | borderRadius: 10, 32 | }, 33 | whiteColor: { 34 | color: '#fff', 35 | }, 36 | justifySpaceBetween: { 37 | justifyContent: 'space-between', 38 | }, 39 | }); 40 | 41 | export default styles; 42 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Profile/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Page} from '../../../../components'; 3 | import {View, Image, Text, TouchableOpacity} from 'react-native'; 4 | import {Card, Divider, FAB, List} from 'react-native-paper'; 5 | import {styles} from './styles'; 6 | import {emmitEvent} from '../../../../api/helper'; 7 | import Provider from './provider'; 8 | import {useTheme} from 'react-native-paper'; 9 | import Locales from '../../../../locales'; 10 | 11 | const Profile = ({navigation, route}) => { 12 | const [user, setUser] = useState({}); 13 | const Theme = useTheme(); 14 | 15 | useEffect(() => { 16 | Provider.getUserById({id: route.params?.id}).then(data => setUser(data)); 17 | }, [route]); 18 | 19 | return ( 20 | 26 | 31 | 32 | 38 | 42 | {user?.fullname} 43 | 44 | 45 | {}}> 52 | { 56 | emmitEvent('core.user.message.send', {touserid: user?.id}); 57 | }} 58 | /> 59 | 64 | {Locales.t('message')} 65 | 66 | 67 | 68 | 69 | } 72 | onPress={() => { 73 | emmitEvent('core.user.details', {id: user?.id}); 74 | }} 75 | /> 76 | 77 | } 80 | onPress={() => { 81 | emmitEvent('core.user.blogmessages', {id: user?.id}); 82 | }} 83 | /> 84 | 85 | } 88 | onPress={() => {}} 89 | /> 90 | 91 | 92 | 93 | 94 | ); 95 | }; 96 | 97 | export default Profile; 98 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Profile/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../../../api/helper'; 2 | 3 | export const getUserById = async ({id}) => { 4 | const response = await Helper.callMoodleWebService( 5 | 'core_user_get_users_by_field', 6 | { 7 | field: 'id', 8 | values: [id], 9 | }, 10 | ); 11 | return response[0]; 12 | }; 13 | 14 | export default {getUserById}; 15 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/Profile/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginHorizontalDefault: { 5 | marginHorizontal: 15, 6 | }, 7 | marginVerticalDefault: { 8 | marginVertical: 15, 9 | }, 10 | centerItems: { 11 | alignItems: 'center', 12 | }, 13 | profileImage: { 14 | width: 100, 15 | height: 100, 16 | borderRadius: 50, 17 | }, 18 | profileFullname: { 19 | marginTop: 15, 20 | fontSize: 20, 21 | }, 22 | messageText: { 23 | paddingTop: 10, 24 | }, 25 | }); 26 | 27 | export default styles; 28 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/AboutSubcontext/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {createStackNavigator} from '@react-navigation/stack'; 3 | 4 | import Profile from './Profile'; 5 | import Details from './Details'; 6 | import BlogMessages from './BlogMessages'; 7 | import Grades from './Grades'; 8 | import GradesView from './Grades/View'; 9 | 10 | const AboutSubcontext = () => { 11 | const Stack = createStackNavigator(); 12 | 13 | return ( 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ); 22 | }; 23 | 24 | export default AboutSubcontext; 25 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/Dashboard/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | 3 | import Provider from './provider'; 4 | import {Page} from '../../../components'; 5 | import Locales from '../../../locales'; 6 | 7 | const Dashboard = ({navigation}) => { 8 | const [blocks, setBlocks] = useState([]); 9 | 10 | useEffect(() => { 11 | Provider.getDashboardBlocks().then(data => { 12 | if (data) { 13 | setBlocks(data); 14 | } 15 | }); 16 | }, []); 17 | 18 | return ( 19 | 23 | {blocks.map(item => ( 24 | 25 | ))} 26 | 27 | ); 28 | }; 29 | 30 | export default Dashboard; 31 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/Dashboard/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService} from '../../../api/helper'; 2 | import { 3 | NotFound, 4 | Timeline, 5 | RecentlyAccessedCourses, 6 | MyOverview, 7 | } from '../../../blocks'; 8 | 9 | export const getBlock = block => { 10 | switch (block) { 11 | case 'timeline': 12 | return Timeline; 13 | case 'recentlyaccessedcourses': 14 | return RecentlyAccessedCourses; 15 | case 'myoverview': 16 | return MyOverview; 17 | default: 18 | return NotFound; 19 | } 20 | }; 21 | 22 | export const getDashboardBlocks = async () => { 23 | try { 24 | const blocks = []; 25 | const data = await callMoodleWebService('core_block_get_dashboard_blocks'); 26 | data.blocks.map(block => 27 | blocks.push({ 28 | Block: getBlock(block.name), 29 | title: block.name, 30 | }), 31 | ); 32 | return blocks; 33 | } catch (error) { 34 | console.error(error); 35 | } 36 | }; 37 | 38 | export default {getDashboardBlocks}; 39 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/Messages/index.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect, useState} from 'react'; 2 | import Provider from './provider'; 3 | import {Page} from '../../../components'; 4 | import Accordion from 'react-native-collapsible/Accordion'; 5 | import {View, TouchableOpacity} from 'react-native'; 6 | import {Card, IconButton, Avatar} from 'react-native-paper'; 7 | import {styles} from './styles'; 8 | import {emmitEvent} from '../../../api/helper'; 9 | import Locales from '../../../locales'; 10 | 11 | const Dashboard = ({navigation, route}) => { 12 | const [activeSections, setActiveSections] = useState([]); 13 | const [privateConversations, setPrivateConversations] = useState([]); 14 | const [groupConversations, setGroupConversations] = useState([]); 15 | const [favouriteConversations, setFavouriteConversations] = useState([]); 16 | 17 | const sections = [ 18 | { 19 | title: `${Locales.t('favorites')} (${favouriteConversations.length})`, 20 | }, 21 | { 22 | title: `${Locales.t('group')} (${groupConversations.length})`, 23 | }, 24 | { 25 | title: `${Locales.t('private')} (${privateConversations.length})`, 26 | }, 27 | ]; 28 | 29 | const renderHeader = (section, _, isActive) => ( 30 | // TODO: Improve with react-native-animatable 31 | 37 | ( 40 | 44 | )} 45 | /> 46 | 47 | ); 48 | 49 | const RenderConversation = ({id = 0, image = '', title, date = 0}) => { 50 | const currentDate = new Date(date * 1000).toLocaleString(undefined, { 51 | year: 'numeric', 52 | month: 'long', 53 | day: 'numeric', 54 | hour: 'numeric', 55 | minute: 'numeric', 56 | }); 57 | 58 | return ( 59 | emmitEvent('core.user.message.send', {id})}> 61 | 62 | } 67 | /> 68 | 69 | 70 | ); 71 | }; 72 | 73 | const renderContent = (_, index, isActive) => { 74 | if (index === 0) { 75 | return ( 76 | 81 | {favouriteConversations.map(value => ( 82 | 0 && value.messages[0].timecreated} 88 | /> 89 | ))} 90 | 91 | ); 92 | } else if (index === 1) { 93 | return ( 94 | 99 | {groupConversations.map(value => ( 100 | 107 | ))} 108 | 109 | ); 110 | } else if (index === 2) { 111 | return ( 112 | 117 | {privateConversations?.map(value => ( 118 | 125 | ))} 126 | 127 | ); 128 | } 129 | }; 130 | 131 | useEffect(() => { 132 | Provider.getPrivateConversations().then(data => 133 | setPrivateConversations(data), 134 | ); 135 | Provider.getGroupConversations().then(data => setGroupConversations(data)); 136 | Provider.getFavouritesConversations().then(data => 137 | setFavouriteConversations(data), 138 | ); 139 | }, []); 140 | 141 | return ( 142 | { 148 | navigation.navigate('messagessubcontext', { 149 | screen: 'settings', 150 | }); 151 | }, 152 | }, 153 | }}> 154 | 155 | setActiveSections(data)} 161 | touchableComponent={props => } 162 | /> 163 | 164 | 165 | ); 166 | }; 167 | 168 | export default Dashboard; 169 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/Messages/provider.js: -------------------------------------------------------------------------------- 1 | import {callMoodleWebService, getCurrentUserDetails} from '../../../api/helper'; 2 | 3 | const conversationsTypes = { 4 | PRIVATE: 1, 5 | GROUP: 2, 6 | FAVOURITES: 3, 7 | }; 8 | 9 | export const getConversations = async ( 10 | userid, 11 | type = conversationsTypes.FAVOURITES, 12 | ) => { 13 | const {conversations} = await callMoodleWebService( 14 | 'core_message_get_conversations', 15 | {userid, type}, 16 | ); 17 | return conversations; 18 | }; 19 | 20 | export const getPrivateConversations = async () => { 21 | const {userid} = await getCurrentUserDetails(); 22 | const conversations = await getConversations( 23 | userid, 24 | conversationsTypes.PRIVATE, 25 | ); 26 | return conversations; 27 | }; 28 | 29 | export const getGroupConversations = async () => { 30 | const {userid} = await getCurrentUserDetails(); 31 | const conversations = await getConversations( 32 | userid, 33 | conversationsTypes.GROUP, 34 | ); 35 | return conversations; 36 | }; 37 | 38 | export const getFavouritesConversations = async () => { 39 | const {userid} = await getCurrentUserDetails(); 40 | const conversations = await getConversations( 41 | userid, 42 | conversationsTypes.FAVOURITES, 43 | ); 44 | return conversations; 45 | }; 46 | 47 | export default { 48 | getConversations, 49 | getPrivateConversations, 50 | getGroupConversations, 51 | getFavouritesConversations, 52 | }; 53 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/Messages/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | headerUnactive: { 5 | borderRadius: 0, 6 | borderBottomWidth: 0, 7 | borderTopWidth: 0, 8 | borderBottomColor: '#fff', 9 | borderTopColor: '#fff', 10 | }, 11 | headerActive: { 12 | marginTop: 15, 13 | marginHorizontal: 15, 14 | }, 15 | marginHorizontal: { 16 | marginHorizontal: 15, 17 | }, 18 | marginBottomDefault: { 19 | marginBottom: 15, 20 | }, 21 | removeBorderRadiusTop: { 22 | borderTopStartRadius: 0, 23 | borderTopEndRadius: 0, 24 | }, 25 | removeBorderRadiusBottom: { 26 | borderBottomStartRadius: 0, 27 | borderBottomEndRadius: 0, 28 | }, 29 | conversationTitle: { 30 | fontSize: 16, 31 | color: '#757575', 32 | }, 33 | }); 34 | 35 | export default styles; 36 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/Settings/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import {Page} from '../../../../components'; 3 | import {Card} from 'react-native-paper'; 4 | import {View, Text, Switch} from 'react-native'; 5 | import {styles} from './styles'; 6 | import Locales from '../../../../locales'; 7 | 8 | const Settings = ({navigation}) => { 9 | const [emailNotification, setEmailNotification] = useState(false); 10 | const [sendWithEnter, setSendWithEnter] = useState(false); 11 | 12 | return ( 13 | 19 | 24 | 25 | 26 | 32 | {Locales.t('email')} 33 | setEmailNotification(!emailNotification)} 36 | /> 37 | 38 | 39 | 40 | 41 | 42 | 48 | {Locales.t('useentertosend')} 49 | setSendWithEnter(!sendWithEnter)} 52 | /> 53 | 54 | 55 | 56 | 57 | ); 58 | }; 59 | 60 | export default Settings; 61 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/Settings/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginVerticalDefault: { 5 | marginVertical: 15, 6 | }, 7 | marginHorizontalDefault: { 8 | marginHorizontal: 15, 9 | }, 10 | marginTopDefault: { 11 | marginTop: 15, 12 | }, 13 | rowDirection: { 14 | flexDirection: 'row', 15 | }, 16 | spaceBetween: { 17 | justifyContent: 'space-between', 18 | }, 19 | alignCenter: { 20 | alignItems: 'center', 21 | }, 22 | }); 23 | 24 | export default styles; 25 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/View/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {Page} from '../../../../components'; 3 | import Provider from './provider'; 4 | import {GiftedChat, Bubble} from 'react-native-gifted-chat'; 5 | import {emmitEvent} from '../../../../api/helper'; 6 | import {View} from 'react-native'; 7 | import RenderHTML from 'react-native-render-html'; 8 | import {styles} from './styles'; 9 | import {useTheme} from 'react-native-paper'; 10 | 11 | const ConversationView = ({navigation, route}) => { 12 | const [conversationId, setConversationId] = useState(null); 13 | const [title, setTitle] = useState(''); 14 | const [currentUser, setCurrentUser] = useState([]); 15 | const [messages, setMessages] = useState([]); 16 | const Theme = useTheme(); 17 | 18 | useEffect(() => { 19 | const getConversationByConvid = async () => { 20 | const response = await Provider.getConversation(route?.params?.id).catch( 21 | error => console.error(error), 22 | ); 23 | return response; 24 | }; 25 | 26 | const getConversationWithUser = async () => { 27 | const response = await Provider.getConversationsBetweenUsers({ 28 | otheruserid: route?.params?.touserid, 29 | }).catch(error => console.error(error)); 30 | return response; 31 | }; 32 | 33 | const getSelfConversation = async () => { 34 | const response = await Provider.getSelfConversation().catch(error => 35 | console.error(error), 36 | ); 37 | return response; 38 | }; 39 | 40 | const wrapper = async () => { 41 | let response; 42 | if (route?.params.id) { 43 | response = await getConversationByConvid(); 44 | } else if (route?.params.touserid === currentUser.userid) { 45 | response = await getSelfConversation(); 46 | } else if (route?.params.touserid) { 47 | response = await getConversationWithUser(); 48 | } 49 | 50 | if (response?.name !== null) { 51 | setTitle(response?.name); 52 | } else { 53 | setTitle(response?.members[0].fullname); 54 | } 55 | 56 | const resultMembers = []; 57 | response?.members.forEach(member => { 58 | resultMembers.push({ 59 | _id: member.id, 60 | name: member.fullname, 61 | avatar: member.profileimageurl, 62 | }); 63 | }); 64 | 65 | resultMembers.push({ 66 | _id: currentUser.userid, 67 | name: currentUser.fullname, 68 | avatar: currentUser.userpictureurl, 69 | }); 70 | 71 | const resultMessages = []; 72 | response?.messages.forEach(({id, text, timecreated, useridfrom}) => { 73 | resultMessages.push({ 74 | _id: id, 75 | text, 76 | createdAt: new Date(timecreated * 1000), 77 | user: resultMembers.find(({_id}) => _id === useridfrom), 78 | }); 79 | }); 80 | 81 | setMessages(resultMessages); 82 | setConversationId(response?.id); 83 | }; 84 | 85 | if (currentUser.userid) { 86 | wrapper(); 87 | } 88 | }, [route, currentUser]); 89 | 90 | useEffect(() => { 91 | (async () => { 92 | const user = await Provider.getCurrentUser().catch(error => 93 | console.error(error), 94 | ); 95 | setCurrentUser(user); 96 | })(); 97 | }, []); 98 | 99 | const renderMessageText = ({currentMessage, ...props}) => { 100 | return ( 101 | 102 | 108 | 109 | ); 110 | }; 111 | 112 | return ( 113 | 120 | { 123 | (async () => { 124 | const response = await Provider.sendMessageToConversations({ 125 | conversationId, 126 | data, 127 | }); 128 | const message = { 129 | _id: response[0]?.id, 130 | text: response[0]?.text, 131 | createdAt: Date.now(), 132 | user: { 133 | _id: currentUser.userid, 134 | name: currentUser.fullname, 135 | avatar: currentUser.userpictureurl, 136 | }, 137 | }; 138 | setMessages(GiftedChat.append(messages, message)); 139 | })(); 140 | }} 141 | user={{ 142 | _id: currentUser.userid, 143 | }} 144 | renderBubble={props => { 145 | return ( 146 | 157 | ); 158 | }} 159 | renderMessageText={props => renderMessageText(props)} 160 | onPressAvatar={user => emmitEvent('core.user.view', {id: user._id})} 161 | /> 162 | 163 | ); 164 | }; 165 | 166 | export default ConversationView; 167 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/View/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../../../api/helper'; 2 | 3 | const getCurrentUser = async () => { 4 | const result = await Helper.getCurrentUserDetails(); 5 | return result; 6 | }; 7 | 8 | const getConversation = async id => { 9 | const {userid} = await Helper.getCurrentUserDetails(); 10 | 11 | await Helper.callMoodleWebService( 12 | 'core_message_mark_all_conversation_messages_as_read ', 13 | { 14 | userid, 15 | conversationid: id, 16 | }, 17 | ); 18 | 19 | const response = await Helper.callMoodleWebService( 20 | 'core_message_get_conversation', 21 | { 22 | userid, 23 | conversationid: id, 24 | includecontactrequests: 0, 25 | includeprivacyinfo: 0, 26 | }, 27 | ); 28 | return response; 29 | }; 30 | 31 | const getConversationsBetweenUsers = async ({otheruserid}) => { 32 | const {userid} = await Helper.getCurrentUserDetails(); 33 | const response = await Helper.callMoodleWebService( 34 | 'core_message_get_conversation_between_users', 35 | { 36 | userid, 37 | otheruserid, 38 | includecontactrequests: 0, 39 | includeprivacyinfo: 0, 40 | }, 41 | ); 42 | return response; 43 | }; 44 | 45 | const getSelfConversation = async () => { 46 | const {userid} = await Helper.getCurrentUserDetails(); 47 | const response = await Helper.callMoodleWebService( 48 | 'core_message_get_self_conversation', 49 | { 50 | userid, 51 | }, 52 | ); 53 | return response; 54 | }; 55 | 56 | const sendMessageToConversations = async ({conversationId, data}) => { 57 | if (conversationId === null) { 58 | return []; 59 | } 60 | 61 | const response = await Helper.callMoodleWebService( 62 | 'core_message_send_messages_to_conversation', 63 | { 64 | conversationid: conversationId, 65 | messages: [ 66 | { 67 | text: data[0].text, 68 | textformat: 2, 69 | }, 70 | ], 71 | }, 72 | ); 73 | return response; 74 | }; 75 | 76 | export default { 77 | getCurrentUser, 78 | getConversation, 79 | getConversationsBetweenUsers, 80 | getSelfConversation, 81 | sendMessageToConversations, 82 | }; 83 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/View/styles.js: -------------------------------------------------------------------------------- 1 | import {StyleSheet} from 'react-native'; 2 | 3 | export const styles = StyleSheet.create({ 4 | marginHorizontalDefault: { 5 | marginHorizontal: 15, 6 | }, 7 | marginVerticalDefault: { 8 | marginVertical: 10, 9 | }, 10 | whiteColor: { 11 | color: 'white', 12 | }, 13 | }); 14 | 15 | export default styles; 16 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/MessagesSubcontext/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {createStackNavigator} from '@react-navigation/stack'; 3 | 4 | import View from './View'; 5 | import Settings from './Settings'; 6 | 7 | const MessagesSubcontext = () => { 8 | const Stack = createStackNavigator(); 9 | 10 | return ( 11 | 12 | 13 | 14 | 15 | ); 16 | }; 17 | 18 | export default MessagesSubcontext; 19 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/index.js: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import {createMaterialBottomTabNavigator} from '@react-navigation/material-bottom-tabs'; 3 | import MaterialIcons from 'react-native-vector-icons/MaterialIcons'; 4 | import Provider from './provider'; 5 | import {useTheme} from 'react-native-paper'; 6 | 7 | import Dashboard from './Dashboard'; 8 | import Messages from './Messages'; 9 | import About from './About'; 10 | import Locales from '../../locales'; 11 | 12 | const DashboardContext = () => { 13 | const [unreadConversations, setUnreadConversations] = useState(0); 14 | const Theme = useTheme(); 15 | 16 | useEffect(() => { 17 | Provider.getUnreadConversationsCount().then(data => 18 | setUnreadConversations(data), 19 | ); 20 | }, []); 21 | 22 | const Tab = createMaterialBottomTabNavigator(); 23 | 24 | return ( 25 | 30 | ( 36 | 37 | ), 38 | }} 39 | /> 40 | ( 46 | 47 | ), 48 | tabBarBadge: unreadConversations !== 0 ? unreadConversations : false, 49 | }} 50 | /> 51 | ( 57 | 58 | ), 59 | }} 60 | /> 61 | 62 | ); 63 | }; 64 | 65 | export default DashboardContext; 66 | -------------------------------------------------------------------------------- /src/screens/DashboardContext/provider.js: -------------------------------------------------------------------------------- 1 | import Helper from '../../api/helper'; 2 | 3 | export const getUnreadConversationsCount = async () => { 4 | const {userid} = await Helper.getCurrentUserDetails(); 5 | const response = await Helper.callMoodleWebService( 6 | 'core_message_get_unread_conversations_count', 7 | { 8 | useridto: userid, 9 | }, 10 | ); 11 | return response; 12 | }; 13 | 14 | export default {getUnreadConversationsCount}; 15 | -------------------------------------------------------------------------------- /src/screens/index.js: -------------------------------------------------------------------------------- 1 | export {default as AuthContext} from './AuthContext'; 2 | export {default as CourseContext} from './CourseContext'; 3 | export {default as DashboardContext} from './DashboardContext'; 4 | export {default as ContextManager} from './ContextManager'; 5 | export {default as AboutSubcontext} from './DashboardContext/AboutSubcontext'; 6 | export { 7 | default as MessagesSubcontext, 8 | } from './DashboardContext/MessagesSubcontext'; 9 | --------------------------------------------------------------------------------