Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c0851ac7 | ||
|
|
7e136faea5 | ||
|
|
309b1e70e6 | ||
|
|
e2399c257d | ||
|
|
c892b51ff8 | ||
|
|
8b3a0d22be | ||
|
|
f4fe9294f0 | ||
|
|
67a2b76e41 | ||
|
|
499e406c5d | ||
|
|
90ccf18fbf | ||
|
|
7f57447e57 | ||
|
|
10beb9935f | ||
|
|
5fc2e1247b | ||
|
|
67d4e97582 | ||
|
|
abeadd858e | ||
|
|
5a737ce38d | ||
|
|
97f1b530b2 | ||
|
|
f1393ae707 | ||
|
|
0c274617cb | ||
|
|
f33a8c3829 | ||
|
|
c243645124 | ||
|
|
4655678481 | ||
|
|
cec8ddeeee | ||
|
|
8d987a02aa | ||
|
|
a6d87d570f | ||
|
|
f3b07be01f | ||
|
|
07f23ba927 | ||
|
|
7a7e96388b | ||
|
|
73d91f7268 | ||
|
|
6371296b28 | ||
|
|
cdeadf9d6d | ||
|
|
c332acb2c1 | ||
|
|
0d68f1a24b | ||
|
|
1666ea88fc | ||
|
|
ff163a31bf | ||
|
|
73d469dc8d | ||
|
|
d0226ab4cc | ||
|
|
3d1b07f11c | ||
|
|
f98d7c26dc | ||
|
|
c5fca74e39 | ||
|
|
f79ad3dabc | ||
|
|
c5ebfa5021 | ||
|
|
534a966ee8 | ||
|
|
7484596fb4 | ||
|
|
1637752b02 | ||
|
|
4ce424d4db | ||
|
|
916af88c53 | ||
|
|
b21776c517 | ||
|
|
6bb128e38a | ||
|
|
8b2694efb7 | ||
|
|
f853132e9b | ||
|
|
39e8d5513a | ||
|
|
6feadf73dd | ||
|
|
d683c48338 | ||
|
|
4a684b0bec | ||
|
|
6d7768e904 | ||
|
|
a645c4530f | ||
|
|
4d61462290 | ||
|
|
877ce8d008 | ||
|
|
fbff91774e | ||
|
|
53fb072373 | ||
|
|
f30f1f47d5 | ||
|
|
d8b0e89c6c | ||
|
|
a353f13ebb | ||
|
|
0d3415441f | ||
|
|
860d509d0f | ||
|
|
c86fdec8e6 | ||
|
|
ca6fedd05c | ||
|
|
07209a79de | ||
|
|
4132416f0d | ||
|
|
e62d5741c2 | ||
|
|
81dca20b17 | ||
|
|
f203f63c36 | ||
|
|
26cd218ec0 | ||
|
|
e402a0376a | ||
|
|
bac202d4ec | ||
|
|
bb8d856d17 | ||
|
|
42075291ce | ||
|
|
32b128fe40 | ||
|
|
df63ab5f91 | ||
|
|
88e3670493 | ||
|
|
eceeed8290 | ||
|
|
caa9c80d44 | ||
|
|
7e76e47d77 | ||
|
|
ba76c9c17e | ||
|
|
9555c6fa76 | ||
|
|
c37a6f5c27 | ||
|
|
b5af71d798 | ||
|
|
8f609fa900 | ||
|
|
5329154121 | ||
|
|
3a9187d795 | ||
|
|
e4e23e8017 | ||
|
|
9638ad4f06 | ||
|
|
c8de700460 | ||
|
|
e0f746b5ae | ||
|
|
9efcc36e15 | ||
|
|
918a7e64bd | ||
|
|
7f6874b791 | ||
|
|
1731462b41 | ||
|
|
654d50cd1b | ||
|
|
f631dd5c7b | ||
|
|
4c5558fa29 | ||
|
|
2892abc7a8 | ||
|
|
529385bc5b | ||
|
|
e3bb5d0fb5 | ||
|
|
2da930cd41 | ||
|
|
f41983a7b6 | ||
|
|
198791ca27 | ||
|
|
5b02ed9b0b | ||
|
|
760bad821b | ||
|
|
b8b2aab9bb | ||
|
|
a2b08606f1 | ||
|
|
5d40bd6f8e | ||
|
|
91639d887f | ||
|
|
6d234672b8 | ||
|
|
4e22b53907 | ||
|
|
f389e315a6 | ||
|
|
7f54c02a1c | ||
|
|
eaaa2b97b4 | ||
|
|
d1362f2ea3 | ||
|
|
2c56c78467 | ||
|
|
ec928c943d | ||
|
|
53bfba0320 | ||
|
|
847c3e85fa | ||
|
|
c96b4afcc7 | ||
|
|
4c741b9ac9 | ||
|
|
6b184c49ad | ||
|
|
6991b99ea9 | ||
|
|
0cc2b4e368 | ||
|
|
c51f834636 | ||
|
|
9a567ff5d0 | ||
|
|
bb420542ef | ||
|
|
14ec13a2e6 | ||
|
|
bf2b038632 | ||
|
|
b2fa6bb3a9 | ||
|
|
53166d9bba | ||
|
|
1560e44d36 | ||
|
|
1dbc8847b1 | ||
|
|
8bbfd1007d | ||
|
|
851e117381 | ||
|
|
2e31a7fbdb | ||
|
|
f3316160fb | ||
|
|
48b92ed2a6 | ||
|
|
4d075095ad | ||
|
|
9c1985bab3 | ||
|
|
e11e1a0d5b | ||
|
|
f202797954 | ||
|
|
f1ee7586f9 | ||
|
|
6cc74488a3 | ||
|
|
dbf9760780 | ||
|
|
6de1e41628 | ||
|
|
9977aac9f6 | ||
|
|
eb4995da86 | ||
|
|
dffff47a9f | ||
|
|
96cc982e01 | ||
|
|
116ab4fcfb | ||
|
|
c9c0249d4f | ||
|
|
85833f91e3 | ||
|
|
b76498852e | ||
|
|
e75b0e51d9 | ||
|
|
6b746bc0b3 | ||
|
|
dd31a59524 | ||
|
|
ca75b44d3b | ||
|
|
d9a9a310a8 | ||
|
|
8ece8cc14d | ||
|
|
425a83faec | ||
|
|
f034b313b3 | ||
|
|
b600cbdc34 | ||
|
|
ad3fce5b17 | ||
|
|
25604657b6 | ||
|
|
996ff027e5 | ||
|
|
71c595df15 | ||
|
|
70d00b7d62 | ||
|
|
e8828d8658 | ||
|
|
e08f6ee73c | ||
|
|
f12460e83a | ||
|
|
baef12a26d | ||
|
|
79400dd2b1 | ||
|
|
4409849143 | ||
|
|
3d77756da0 |
No files matched your search
@@ -5,7 +5,7 @@ To make it possible for us to help you, please fill out below information carefu
|
||||
|
||||
Before reporting any issues, please make sure that you're using the latest version.
|
||||
|
||||
We are also available on live chat at https://chat.lbry.io
|
||||
We are also available on live chat at https://chat.lbry.com
|
||||
-->
|
||||
|
||||
|
||||
@@ -34,3 +34,22 @@ Tell us what happens instead
|
||||
|
||||
## Screenshots
|
||||
<!-- If a screenshot would help explain the bug, please include one or two here -->
|
||||
|
||||
## Internal Use
|
||||
|
||||
### Acceptance Criteria
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
### Definition of Done
|
||||
- [ ] Tested against acceptance criteria
|
||||
- [ ] Tested against the assumptions of the user story
|
||||
- [ ] The project builds without errors
|
||||
- [ ] Unit tests are written and passing
|
||||
- [ ] Tests on devices/browsers listed in the issue have passed
|
||||
- [ ] QA performed & issues resolved
|
||||
- [ ] Refactoring completed
|
||||
- [ ] Any configuration or build changes documented
|
||||
- [ ] Documentation updated
|
||||
- [ ] Peer Code Review performed
|
||||
@@ -9,3 +9,7 @@ src/main/assets/index.android.bundle.meta
|
||||
*.log
|
||||
.vagrant
|
||||
|
||||
lbry-android.keystore
|
||||
p4a/pythonforandroid/bootstraps/lbry/build/templates/google-services.json
|
||||
.gitsecret/keys/random_seed
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
stages:
|
||||
- build
|
||||
- deploy
|
||||
- release
|
||||
|
||||
build apk:
|
||||
stage: build
|
||||
image: lbry/android-base:latest
|
||||
before_script:
|
||||
- export BUILD_VERSION=$(cat $CI_PROJECT_DIR/src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
|
||||
artifacts:
|
||||
paths:
|
||||
- bin/browser-*-release.apk
|
||||
script:
|
||||
- export PATH=/usr/bin:$PATH
|
||||
- echo "$PGP_PRIVATE_KEY" | gpg --batch --import
|
||||
- cd app
|
||||
- npm install
|
||||
- cd ..
|
||||
- wget -q 'https://eu.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P ~/.buildozer/android/
|
||||
- tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C ~/.buildozer/android/
|
||||
- rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
- ln -s ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
- cp -f $CI_PROJECT_DIR/scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
- cp -f $CI_PROJECT_DIR/scripts/mangled-glibc-syscalls.h ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21/arch-arm/usr/include/crystax/bionic/libc/include/sys/mangled-glibc-syscalls.h
|
||||
- rm ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz
|
||||
- git secret reveal
|
||||
- mv buildozer.spec.travis buildozer.spec
|
||||
- "./release.sh | grep -Fv -e 'working:' -e 'copy' -e 'Compiling' --line-buffered"
|
||||
- cp $CI_PROJECT_DIR/bin/browser-$BUILD_VERSION-release.apk /dev/null
|
||||
|
||||
deploy build.lbry.io:
|
||||
image: python:latest
|
||||
stage: deploy
|
||||
dependencies:
|
||||
- build apk
|
||||
before_script:
|
||||
- pip install awscli
|
||||
- export BUILD_VERSION=$(cat $CI_PROJECT_DIR/src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
|
||||
- export BUILD_APK_FILENAME=browser-$BUILD_VERSION-release.apk
|
||||
script:
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME s3://build.lbry.io/android/build-${CI_PIPELINE_IID}_commit-${CI_COMMIT_SHA:0:7}/$BUILD_APK_FILENAME
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME s3://build.lbry.io/android/push.apk
|
||||
|
||||
release apk:
|
||||
image: python:latest
|
||||
stage: release
|
||||
only:
|
||||
- tags
|
||||
dependencies:
|
||||
- build apk
|
||||
before_script:
|
||||
- pip install awscli githubrelease
|
||||
- export BUILD_VERSION=$(cat $CI_PROJECT_DIR/src/main/python/main.py | grep --color=never -oP '([0-9]+\.?)+')
|
||||
- export BUILD_APK_FILENAME=browser-$BUILD_VERSION-release.apk
|
||||
script:
|
||||
- githubrelease release lbryio/lbry-android create $CI_COMMIT_TAG --publish bin/$BUILD_APK_FILENAME
|
||||
- aws s3 cp bin/$BUILD_APK_FILENAME s3://build.lbry.io/android/latest.apk
|
||||
Whitespace-only changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
lbry-android.keystore:
|
||||
p4a/pythonforandroid/bootstraps/lbry/build/templates/google-services.json
|
||||
+15
-9
@@ -1,15 +1,17 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
language: python
|
||||
python:
|
||||
- '2.7'
|
||||
- '3.7'
|
||||
install:
|
||||
- deactivate
|
||||
- export PATH=/usr/bin:$PATH
|
||||
- export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
|
||||
- sudo dpkg --add-architecture i386
|
||||
- sudo add-apt-repository ppa:deadsnakes/ppa -y
|
||||
- sudo apt-get -qq update
|
||||
- sudo apt-get -qq install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
|
||||
- sudo pip install --upgrade cython==0.25.2 pip setuptools
|
||||
- sudo apt-get -qq install build-essential python3.7 python3.7-dev python3.7-venv python3-pip ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
|
||||
- sudo pip install --upgrade cython==0.28.1 pip setuptools
|
||||
- wget -q https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz
|
||||
- tar -xf node-v8.11.1-linux-x64.tar.xz
|
||||
- sudo ln -s $TRAVIS_BUILD_DIR/node-v8.11.1-linux-x64/bin/node /usr/bin/node
|
||||
@@ -26,20 +28,24 @@ install:
|
||||
- cd ..
|
||||
- mv buildozer.spec.travis buildozer.spec
|
||||
- mkdir -p cd ~/.buildozer/android/platform/
|
||||
- wget -q 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P ~/.buildozer/android/platform/
|
||||
- wget -q 'https://dist.testnet.lbry.tech/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P ~/.buildozer/android/
|
||||
- wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/
|
||||
- wget -q 'https://dl.google.com/android/repository/platform-27_r01.zip' -P ~/.buildozer/android/platform/
|
||||
- wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P ~/.buildozer/android/platform/
|
||||
- unzip -qq ~/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d ~/.buildozer/android/platform/
|
||||
- wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.2-linux.zip' -P ~/.buildozer/android/platform/
|
||||
- tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C ~/.buildozer/android/
|
||||
- cp -f $TRAVIS_BUILD_DIR/scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
- rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
- ln -s ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
- tar -xf ~/.buildozer/android/platform/android-sdk_r23-linux.tgz -C ~/.buildozer/android/platform/
|
||||
- mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23
|
||||
- unzip -qq ~/.buildozer/android/platform/platform-27_r01.zip -d ~/.buildozer/android/platform/android-sdk-23/platforms
|
||||
- mv ~/.buildozer/android/platform/android-sdk-23/platforms/android-8.1.0 ~/.buildozer/android/platform/android-sdk-23/platforms/android-27
|
||||
- mkdir -p ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
- unzip -qq ~/.buildozer/android/platform/build-tools_r26.0.1-linux.zip -d ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
- mv ~/.buildozer/android/platform/android-sdk-23/build-tools/android-8.0.0 ~/.buildozer/android/platform/android-sdk-23/build-tools/26.0.1
|
||||
- unzip -qq ~/.buildozer/android/platform/build-tools_r26.0.2-linux.zip -d ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
- mv ~/.buildozer/android/platform/android-sdk-23/build-tools/android-8.1.0 ~/.buildozer/android/platform/android-sdk-23/build-tools/26.0.2
|
||||
- mkdir -p ~/.buildozer/android/platform/android-sdk-23/licenses
|
||||
- echo $'\nd56f5187479451eabf01fb78af6dfcb131a6481e' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-license
|
||||
- echo $'\n84831b9409646a918e30573bab4c9c91346d8abd' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-preview-license
|
||||
script:
|
||||
- "./release.sh | grep -Fv -e 'working:' -e 'copy' -e 'Compiling' --line-buffered"
|
||||
- cp $TRAVIS_BUILD_DIR/bin/*.apk /dev/null
|
||||
|
||||
@@ -7,23 +7,24 @@ This app has currently only been built on Ubuntu 14.04, 16.04, 17.10, and 18.04,
|
||||
#### Requirements
|
||||
* JDK 1.8
|
||||
* Android SDK
|
||||
* Android NDK
|
||||
* Crystax Android NDK
|
||||
* Buildozer
|
||||
* Node.js
|
||||
* npm
|
||||
* yarn
|
||||
|
||||
#### Apt Packages
|
||||
Based on the quickstart instructions at http://buildozer.readthedocs.io/en/latest/installation.html
|
||||
#### apt Packages
|
||||
Based on the quick-start instructions at http://buildozer.readthedocs.io/en/latest/installation.html
|
||||
```
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install autoconf autogen build-essential libtool python python-pip python-openssl ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
|
||||
sudo apt-get install autoconf autogen build-essential curl libtool libffi-dev python python-pip python-openssl python3.7 python3.7-dev python3-pip ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386
|
||||
```
|
||||
Alternatively, the JDK available from http://www.oracle.com/technetwork/java/javase/downloads/index.html can be installed instead of the `openjdk-8-jdk` package.
|
||||
|
||||
#### Install Cython
|
||||
#### Install Cython and Setuptools
|
||||
```
|
||||
sudo pip install --upgrade cython==0.25.2 setuptools
|
||||
sudo pip install --upgrade cython==0.28.1 setuptools
|
||||
```
|
||||
|
||||
#### Install buildozer
|
||||
@@ -43,8 +44,8 @@ Assuming `lbry-android` as the current working folder:
|
||||
| Setting | Description |
|
||||
|:------------------- |:-----------------------------|
|
||||
| title | application title |
|
||||
| package.name | package name (eg. browser) |
|
||||
| package.domain | package domain (eg. io.lbry) |
|
||||
| package.name | package name (e.g. browser) |
|
||||
| package.domain | package domain (e.g. io.lbry) |
|
||||
| source.dir | the location of the application main.py |
|
||||
| version | application version |
|
||||
| requirements | the Python module requirements for building the application |
|
||||
@@ -52,12 +53,52 @@ Assuming `lbry-android` as the current working folder:
|
||||
| android.permissions | Android manifest permissions required by the application. This should be set to `INTERNET` at the very least to enable internet connectivity |
|
||||
| android.api | Android API version (Should be at least 23 for Gradle build support) |
|
||||
| android.sdk | Android SDK version (Should be at least 23 for Gradle build support) |
|
||||
| android.ndk | Android NDK version (13b has been tested to result in a successful build) |
|
||||
| android.ndk_path | Android NDK path. buildozer will automatically download this if not set |
|
||||
| android.sdk_path | Android SDK path. buildozer will automatically download this if not set |
|
||||
| android.ndk | Android NDK version (not required when using crystax Android NDK) |
|
||||
| android.ndk_path | Android NDK path. This should be set to the crystax Android NDK path) |
|
||||
| android.sdk_path | Android SDK path. This should be set to the path where the Android SDK is manually set up (if not set up in the `.buildozer` path). |
|
||||
| p4a.source_dir | Path to the python-for-android repository folder. Currently set to the included `p4a` folder |
|
||||
| p4a.local_recipes | Path to a folder containing python_for_android recipes to be used in the build. The included `recipes` folder includes recipes for a successful build |
|
||||
|
||||
#### Setup Android SDK for buildozer
|
||||
Download the Android SDK, platform and build tools archives.
|
||||
* Android API 23 SDK - https://dl.google.com/android/android-sdk_r23-linux.tgz
|
||||
* Android API 27 platform - https://dl.google.com/android/repository/platform-27_r01.zip
|
||||
* Android build tools 26.0.1 - https://dl.google.com/android/repository/build-tools_r26.0.1-linux.
|
||||
|
||||
Create the `.buildozer` path (and the `android` sub-path) in your home folder if it doesn't already exist.
|
||||
`mkdir ~/.buildozer`
|
||||
`mkdir ~/.buildozer/android`
|
||||
|
||||
Extract the API 23 SDK to the `~/.buildozer/android` path and rename the extracted folder.
|
||||
```
|
||||
tar -xf android-sdk_r23-linux.tgz ~/.buildozer/android/platform/
|
||||
mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23
|
||||
```
|
||||
|
||||
Extract the API 27 platform archive into the `android-sdk-23` folder and rename the extracted folder.
|
||||
```
|
||||
unzip platform-27_r01.zip -d ~/.buildozer/android/platform/android-sdk-23/platforms
|
||||
mv ~/.buildozer/android/platform/android-sdk-23/platforms/android-8.1.0 ~/.buildozer/android/platform/android-sdk-23/platforms/android-27
|
||||
```
|
||||
|
||||
Extract the build tools 26.0.1 build tools into the `android-sdk-23` folder and rename the extracted folder.
|
||||
```
|
||||
mkdir -p ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
unzip ~/.buildozer/android/platform/build-tools_r26.0.1-linux.zip -d ~/.buildozer/android/platform/android-sdk-23/build-tools
|
||||
mv ~/.buildozer/android/platform/android-sdk-23/build-tools/android-8.0.0 ~/.buildozer/android/platform/android-sdk-23/build-tools/26.0.1
|
||||
```
|
||||
|
||||
Finally, create the Android SDK license file. This prevents being prompted to accept the SDK license during the build process.
|
||||
```
|
||||
mkdir -p ~/.buildozer/android/platform/android-sdk-23/licenses
|
||||
echo $'\nd56f5187479451eabf01fb78af6dfcb131a6481e' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-license
|
||||
```
|
||||
|
||||
#### Setup Crystax Android NDK for buildozer
|
||||
* Download the Crystax Android NDK from https://us.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz and extract. Remember to update `android.ndk_path` in your `buildozer.spec` to the path of the extracted Crystax NDK archive.
|
||||
* Copy `build-target-python.sh` from the `scripts` folder in the cloned `lbry-android` repository to the `crystax-ndk-10.3.2/build/tools/` folder.
|
||||
* Delete the `android-9` folder in `crystax-ndk-10.3.2/platforms`, and create a symbolic link named `android-9` to the `android-21` folder.
|
||||
|
||||
#### Build and Deploy
|
||||
Run `npm i` in the `lbry-android/app` folder to install the necessary modules required by the React Native user interface.
|
||||
|
||||
@@ -69,7 +110,7 @@ To build and deploy, you can run `./deploy.sh`. This requires a connected device
|
||||
If you already installed `Android SDK` and `adb`
|
||||
|
||||
* Run `adb reverse tcp:8081 tcp:8081`
|
||||
* Then go to the `lbry-android/app` folder and run `npm start`
|
||||
* Then go to the `lbry-android/app` folder and run `npm start`
|
||||
|
||||
Note: You need to have your device connected with USB debugging.
|
||||
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
### Introduction
|
||||
If you would like to contribute to the Android app, but find the build documentation a little daunting, this guide lets you copy-paste your way to a successful APK build.
|
||||
|
||||
#### Estimated build time
|
||||
25 - 40 minutes (depending on Internet connection speeds)
|
||||
|
||||
#### What do you need?
|
||||
* A computer running Ubuntu 18.04
|
||||
* Internet access to download modules and packages.
|
||||
* At least 15GB of free disk space.
|
||||
* Alternatively, Docker. You can skip steps 1 through 5 if you make use of the `lbry/android-base` Docker base image. Scroll down to Fast track if you would prefer to use Docker.
|
||||
|
||||
### Step 1 of 10
|
||||
Install all the apt packages required by running the following commands. You can copy-paste directly to your terminal.
|
||||
```
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get -y update
|
||||
sudo apt-get install -y curl ca-certificates software-properties-common gpg-agent wget
|
||||
sudo add-apt-repository ppa:deadsnakes/ppa -y && \
|
||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
sudo apt-get -y update && apt-get -y install autoconf autogen automake libtool libffi-dev \
|
||||
build-essential python3.7 python3.7-dev python3.7-venv python3-pip ccache git libncurses5:i386 libstdc++6:i386 \
|
||||
libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev \
|
||||
python-pip openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 yarn gawk nodejs npm
|
||||
```
|
||||
|
||||
### Step 2 of 10
|
||||
Install a couple of packages using the Python package installer
|
||||
```
|
||||
sudo -H pip install --upgrade cython==0.28.1 setuptools
|
||||
```
|
||||
|
||||
### Step 3 of 10
|
||||
Install buildozer, a tool for creating the apk package using the python for android toolcahin.
|
||||
```
|
||||
git clone https://github.com/lbryio/buildozer.git
|
||||
cd buildozer && python2.7 setup.py install && cd ..
|
||||
```
|
||||
|
||||
### Step 4 of 10
|
||||
The Android SDK needs to be setup for buildozer. This requires creating a few directories and downloading a number of files. Run the following commands to create the buildozer directory, download the required archives and extract them into their proper destination folders.
|
||||
|
||||
```
|
||||
mkdir -p ~/.buildozer/android/platform
|
||||
wget 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/ && \
|
||||
wget 'https://dl.google.com/android/repository/platform-28_r06.zip' -P ~/.buildozer/android/platform/ && \
|
||||
wget 'https://dl.google.com/android/repository/build-tools_r26.0.2-linux.zip' -P ~/.buildozer/android/platform/
|
||||
tar -xvf ~/.buildozer/android/platform/android-sdk_r23-linux.tgz -C ~/.buildozer/android/platform/ && \
|
||||
mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23 && \
|
||||
unzip ~/.buildozer/android/platform/platform-28_r06.zip -d ~/.buildozer/android/platform/android-sdk-23/platforms && \
|
||||
mv ~/.buildozer/android/platform/android-sdk-23/platforms/android-9 ~/.buildozer/android/platform/android-sdk-23/platforms/android-28 && \
|
||||
mkdir -p ~/.buildozer/android/platform/android-sdk-23/build-tools && \
|
||||
unzip ~/.buildozer/android/platform/build-tools_r26.0.2-linux.zip -d ~/.buildozer/android/platform/android-sdk-23/build-tools && \
|
||||
mkdir -p ~/.buildozer/android/platform/android-sdk-23/licenses && \
|
||||
echo $'\nd56f5187479451eabf01fb78af6dfcb131a6481e' > ~/.buildozer/android/platform/android-sdk-23/licenses/android-sdk-license
|
||||
```
|
||||
|
||||
### Step 5 of 10
|
||||
Install the react-native-cli npm package.
|
||||
```
|
||||
sudo npm install -g react-native-cli
|
||||
```
|
||||
|
||||
### Step 6 of 10
|
||||
Install the Crystax NDK which is required for building Python 3.7 for the mobile app, and a number of native C / C++ modules and packages used by the app. Run the following commands to download and extract the NDK.
|
||||
```
|
||||
wget 'https://www.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P ~/.buildozer/android/ && \
|
||||
tar -xvf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C ~/.buildozer/android/ && \
|
||||
rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9 && \
|
||||
ln -s ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
```
|
||||
|
||||
### Step 7 of 10
|
||||
Clone the lbryio/lbry-android git repository and create your buildozer.spec file. The provide buildozer.spec.sample contains defaults provided you followed steps 1 through 5 exactly as described. You can also customise the spec file if you want to.
|
||||
```
|
||||
git clone https://github.com/lbryio/lbry-android
|
||||
cd lbry-android
|
||||
cp buildozer.spec.sample buildozer.spec
|
||||
```
|
||||
|
||||
### Step 8 of 10
|
||||
Install the npm packages required for the app's React Native code.
|
||||
```
|
||||
cd app
|
||||
npm install
|
||||
cd ..
|
||||
```
|
||||
|
||||
### Step 9 of 10
|
||||
Copy a couple of required files from the repository for the build to be successful.
|
||||
```
|
||||
cp scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
cp scripts/mangled-glibc-syscalls.h ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21/arch-arm/usr/include/crystax/bionic/libc/include/sys/mangled-glibc-syscalls.h
|
||||
```
|
||||
|
||||
### Step 10 of 10
|
||||
If you made it this far, you're finally ready to build the package! You just have to run a single command to generate the APK.
|
||||
```
|
||||
buildozer android debug
|
||||
```
|
||||
|
||||
### Fast Track
|
||||
Install Docker and start a container using the `lbry/android-base` image, which is about 1.72GB in size. Run the following commands for Ubuntu and then follow steps 6 through 10 in the container's bash prompt.
|
||||
```
|
||||
sudo apt-get install docker-ce
|
||||
docker run -it lbry/android-base:latest /bin/bash
|
||||
```
|
||||
|
||||
**Protip:** You can also make use of Docker to run your builds on macOS or Windows.
|
||||
@@ -1,7 +1,7 @@
|
||||
# LBRY Android
|
||||
[](https://travis-ci.org/lbryio/lbry-android)
|
||||
[](https://ci.lbry.tech/lbry/lbry-android/commits/master)
|
||||
|
||||
An Android browser and wallet for the [LBRY](https://lbry.io) network. This app bundles [lbrynet-daemon](https://github.com/lbryio/lbry) as a background service with a UI layer built with React Native. The APK is built using buildozer and the Gradle build tool.
|
||||
An Android browser and wallet for the [LBRY](https://lbry.com) network. This app bundles [lbrynet-daemon](https://github.com/lbryio/lbry) as a background service with a UI layer built with React Native. The APK is built using buildozer and the Gradle build tool.
|
||||
|
||||
<img src="https://spee.ch/8/lbry-android.png" alt="LBRY Android Screenshot" width="384px" />
|
||||
|
||||
@@ -12,7 +12,7 @@ The minimum supported Android version is 5.0 Lollipop. There are two ways to ins
|
||||
1. Direct APK install available at [http://build.lbry.io/android/latest.apk](http://build.lbry.io/android/latest.apk). You will need to enable installation from third-party sources on your device in order to install from this source.
|
||||
|
||||
## Usage
|
||||
The app can be launched by opening **LBRY Browser** from the device's app drawer or via the shortcut on the homescreen if that was created upon install.
|
||||
The app can be launched by opening **LBRY Browser** from the device's app drawer or via the shortcut on the home screen if that was created upon installation.
|
||||
|
||||
## Running from Source
|
||||
The app is built from source via [Buildozer](https://github.com/kivy/buildozer). After cloning the repository, copy `buildozer.spec.sample` to `buildozer.spec` and modify this file as necessary for your environment. Please see [BUILD.md](BUILD.md) for detailed build instructions.
|
||||
@@ -24,7 +24,7 @@ Contributions to this project are welcome, encouraged, and compensated. For more
|
||||
This project is MIT licensed. For the full license, see [LICENSE](LICENSE).
|
||||
|
||||
## Security
|
||||
We take security seriously. Please contact security@lbry.io regarding any security issues. Our PGP key is [here](https://keybase.io/lbry/key.asc) if you need it.
|
||||
We take security seriously. Please contact security@lbry.com regarding any security issues. Our PGP key is [here](https://keybase.io/lbry/key.asc) if you need it.
|
||||
|
||||
## Contact
|
||||
The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.io)
|
||||
The primary contact for this project is [@akinwale](https://github.com/akinwale) (akinwale@lbry.com)
|
||||
Vendored
+7
-4
@@ -43,7 +43,7 @@ Vagrant.configure("2") do |config|
|
||||
dpkg --add-architecture i386
|
||||
apt-get update
|
||||
apt-get install -y libssl-dev
|
||||
apt-get install -y autoconf libffi-dev pkg-config libtool build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 python-pip
|
||||
apt-get install -y python3.6 python3.6-dev python3-pip autoconf libffi-dev pkg-config libtool build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 python-pip
|
||||
pip install -f --upgrade setuptools pyopenssl
|
||||
git clone https://github.com/lbryio/buildozer.git
|
||||
cd buildozer
|
||||
@@ -63,12 +63,15 @@ Vagrant.configure("2") do |config|
|
||||
cp $HOME/lbry-android/buildozer.spec.vagrant $HOME/lbry-android/buildozer.spec
|
||||
|
||||
mkdir -p cd $HOME/.buildozer/android/platform/
|
||||
wget -q 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P $HOME/.buildozer/android/platform/
|
||||
wget -q 'https://us.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P $HOME/.buildozer/android/
|
||||
wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P $HOME/.buildozer/android/platform/
|
||||
wget -q 'https://dl.google.com/android/repository/platform-27_r01.zip' -P $HOME/.buildozer/android/platform/
|
||||
wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P $HOME/.buildozer/android/platform/
|
||||
unzip -qq $HOME/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d $HOME/.buildozer/android/platform/
|
||||
rm $HOME/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip
|
||||
tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C $HOME/.buildozer/android/
|
||||
rm $HOME/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz
|
||||
ln -s $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
cp -f $HOME/lbry-android/scripts/build-target-python.sh $HOME/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
rm -rf $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
tar -xf $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz -C $HOME/.buildozer/android/platform/
|
||||
rm $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz
|
||||
mv $HOME/.buildozer/android/platform/android-sdk-linux $HOME/.buildozer/android/platform/android-sdk-23
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"presets": ["module:metro-react-native-babel-preset"],
|
||||
"plugins": [
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||
["module-resolver", {
|
||||
root: ["./src"],
|
||||
}],
|
||||
]
|
||||
}
|
||||
Generated
+3130
-1988
File diff suppressed because it is too large.
Load diff
+20
-11
@@ -7,32 +7,41 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"base-64": "^0.1.0",
|
||||
"@expo/vector-icons": "^8.1.0",
|
||||
"lbry-redux": "lbryio/lbry-redux",
|
||||
"lbryinc": "lbryio/lbryinc",
|
||||
"lodash": ">=4.17.11",
|
||||
"merge": ">=1.2.1",
|
||||
"moment": "^2.22.1",
|
||||
"react": "16.2.0",
|
||||
"react-native": "0.55.3",
|
||||
"react": "16.8.6",
|
||||
"react-native": "0.59.3",
|
||||
"@react-native-community/async-storage": "^1.2.2",
|
||||
"react-native-country-picker-modal": "^0.6.2",
|
||||
"react-native-exception-handler": "2.9.0",
|
||||
"react-native-fast-image": "^5.0.3",
|
||||
"react-native-fetch-blob": "^0.10.8",
|
||||
"react-native-gesture-handler": "^1.1.0",
|
||||
"react-native-image-zoom-viewer": "^2.2.5",
|
||||
"react-native-password-strength-meter": "^0.0.2",
|
||||
"react-native-phone-input": "lbryio/react-native-phone-input",
|
||||
"react-native-vector-icons": "^5.0.0",
|
||||
"react-native-vector-icons": "^6.4.2",
|
||||
"react-native-video": "lbryio/react-native-video#exoplayer-lbry-android",
|
||||
"react-navigation": "^2.12.1",
|
||||
"react-navigation-redux-helpers": "^2.0.5",
|
||||
"react-navigation": "^3.11.0",
|
||||
"react-navigation-redux-helpers": "^3.0.2",
|
||||
"react-redux": "^5.0.3",
|
||||
"redux": "^3.6.0",
|
||||
"redux-logger": "3.0.6",
|
||||
"redux-persist": "^4.8.0",
|
||||
"redux-persist-filesystem-storage": "^1.2.0",
|
||||
"redux-persist": "^4.10.2",
|
||||
"redux-persist-filesystem-storage": "^1.3.2",
|
||||
"redux-persist-transform-compress": "^4.2.0",
|
||||
"redux-persist-transform-filter": "0.0.10",
|
||||
"redux-thunk": "^2.2.0"
|
||||
"redux-persist-transform-filter": "0.0.18",
|
||||
"redux-thunk": "^2.3.0",
|
||||
"rn-fetch-blob": "^0.10.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.3",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-preset-react-native": "5.0.2",
|
||||
"babel-preset-stage-2": "^6.18.0",
|
||||
"babel-plugin-module-resolver": "^3.1.1",
|
||||
"flow-babel-webpack-plugin": "^1.1.1"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 354 KiB |
+121
-103
@@ -1,40 +1,43 @@
|
||||
import React from 'react';
|
||||
import AboutPage from '../page/about';
|
||||
import DiscoverPage from '../page/discover';
|
||||
import DownloadsPage from '../page/downloads';
|
||||
import FilePage from '../page/file';
|
||||
import FirstRunScreen from '../page/firstRun';
|
||||
import RewardsPage from '../page/rewards';
|
||||
import TrendingPage from '../page/trending';
|
||||
import SearchPage from '../page/search';
|
||||
import SettingsPage from '../page/settings';
|
||||
import SplashScreen from '../page/splash';
|
||||
import TransactionHistoryPage from '../page/transactionHistory';
|
||||
import WalletPage from '../page/wallet';
|
||||
import SearchInput from '../component/searchInput';
|
||||
import AboutPage from 'page/about';
|
||||
import DiscoverPage from 'page/discover';
|
||||
import DownloadsPage from 'page/downloads';
|
||||
import DrawerContent from 'component/drawerContent';
|
||||
import FilePage from 'page/file';
|
||||
import FirstRunScreen from 'page/firstRun';
|
||||
import RewardsPage from 'page/rewards';
|
||||
import TrendingPage from 'page/trending';
|
||||
import SearchPage from 'page/search';
|
||||
import SettingsPage from 'page/settings';
|
||||
import SplashScreen from 'page/splash';
|
||||
import SubscriptionsPage from 'page/subscriptions';
|
||||
import TransactionHistoryPage from 'page/transactionHistory';
|
||||
import VerificationScreen from 'page/verification';
|
||||
import WalletPage from 'page/wallet';
|
||||
import {
|
||||
createDrawerNavigator,
|
||||
createStackNavigator,
|
||||
NavigationActions
|
||||
} from 'react-navigation';
|
||||
import {
|
||||
addListener,
|
||||
reduxifyNavigator,
|
||||
createReduxContainer,
|
||||
createReactNavigationReduxMiddleware,
|
||||
createNavigationReducer
|
||||
} from 'react-navigation-redux-helpers';
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
AppState,
|
||||
AsyncStorage,
|
||||
BackHandler,
|
||||
Linking,
|
||||
NativeModules,
|
||||
TextInput,
|
||||
ToastAndroid
|
||||
} from 'react-native';
|
||||
import { doDeleteCompleteBlobs } from '../redux/actions/file';
|
||||
import { SETTINGS, doHideNotification, doNotify, selectNotification } from 'lbry-redux';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import { SETTINGS, doDismissToast, doToast, selectToast } from 'lbry-redux';
|
||||
import {
|
||||
doGetSync,
|
||||
doUserCheckEmailVerified,
|
||||
doUserEmailVerify,
|
||||
doUserEmailVerifyFailure,
|
||||
selectEmailToVerify,
|
||||
@@ -42,16 +45,17 @@ import {
|
||||
selectEmailVerifyErrorMessage,
|
||||
selectUser
|
||||
} from 'lbryinc';
|
||||
import { makeSelectClientSetting } from '../redux/selectors/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { decode as atob } from 'base-64';
|
||||
import { dispatchNavigateToUri } from '../utils/helper';
|
||||
import Colors from '../styles/colors';
|
||||
import Constants from '../constants';
|
||||
import { dispatchNavigateBack, dispatchNavigateToUri } from 'utils/helper';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import NavigationButton from '../component/navigationButton';
|
||||
import discoverStyle from '../styles/discover';
|
||||
import searchStyle from '../styles/search';
|
||||
import SearchRightHeaderIcon from '../component/searchRightHeaderIcon';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import searchStyle from 'styles/search';
|
||||
import SearchRightHeaderIcon from 'component/searchRightHeaderIcon';
|
||||
|
||||
const menuNavigationButton = (navigation) => <NavigationButton
|
||||
name="bars"
|
||||
@@ -64,92 +68,77 @@ const discoverStack = createStackNavigator({
|
||||
Discover: {
|
||||
screen: DiscoverPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'Discover',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
})
|
||||
title: 'Explore',
|
||||
header: null
|
||||
}),
|
||||
},
|
||||
File: {
|
||||
screen: FilePage,
|
||||
navigationOptions: {
|
||||
header: null,
|
||||
drawerLockMode: 'locked-closed'
|
||||
}
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
header: null
|
||||
})
|
||||
},
|
||||
Search: {
|
||||
screen: SearchPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
drawerLockMode: 'locked-closed'
|
||||
header: null
|
||||
})
|
||||
}
|
||||
}, {
|
||||
headerMode: 'screen'
|
||||
headerMode: 'screen',
|
||||
transitionConfig: () => ({ screenInterpolator: () => null }),
|
||||
});
|
||||
|
||||
const trendingStack = createStackNavigator({
|
||||
Trending: {
|
||||
screen: TrendingPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'Trending',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
})
|
||||
}
|
||||
});
|
||||
discoverStack.navigationOptions = ({ navigation }) => {
|
||||
let drawerLockMode = 'unlocked';
|
||||
/*if (navigation.state.index > 0) {
|
||||
drawerLockMode = 'locked-closed';
|
||||
}*/
|
||||
|
||||
const myLbryStack = createStackNavigator({
|
||||
Downloads: {
|
||||
screen: DownloadsPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'My LBRY',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
const rewardsStack = createStackNavigator({
|
||||
Rewards: {
|
||||
screen: RewardsPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'Rewards',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
})
|
||||
}
|
||||
});
|
||||
return {
|
||||
drawerLockMode
|
||||
};
|
||||
};
|
||||
|
||||
const walletStack = createStackNavigator({
|
||||
Wallet: {
|
||||
screen: WalletPage,
|
||||
navigationOptions: ({ navigation }) => ({
|
||||
title: 'Wallet',
|
||||
headerLeft: menuNavigationButton(navigation),
|
||||
header: null
|
||||
})
|
||||
},
|
||||
TransactionHistory: {
|
||||
screen: TransactionHistoryPage,
|
||||
navigationOptions: {
|
||||
title: 'Transaction History',
|
||||
drawerLockMode: 'locked-closed'
|
||||
header: null
|
||||
}
|
||||
}
|
||||
}, {
|
||||
headerMode: 'screen'
|
||||
headerMode: 'screen',
|
||||
transitionConfig: () => ({ screenInterpolator: () => null }),
|
||||
});
|
||||
|
||||
const drawer = createDrawerNavigator({
|
||||
DiscoverStack: { screen: discoverStack, navigationOptions: {
|
||||
title: 'Discover', drawerIcon: ({ tintColor }) => <Icon name="compass" size={20} style={{ color: tintColor }} />
|
||||
title: 'Explore', drawerIcon: ({ tintColor }) => <Icon name="home" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
TrendingStack: { screen: trendingStack, navigationOptions: {
|
||||
TrendingStack: { screen: TrendingPage, navigationOptions: {
|
||||
title: 'Trending', drawerIcon: ({ tintColor }) => <Icon name="fire" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
MyLBRYStack: { screen: myLbryStack, navigationOptions: {
|
||||
title: 'My LBRY', drawerIcon: ({ tintColor }) => <Icon name="folder" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
Rewards: { screen: rewardsStack, navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="trophy" size={20} style={{ color: tintColor }} />
|
||||
MySubscriptionsStack: { screen: SubscriptionsPage, navigationOptions: {
|
||||
title: 'Subscriptions', drawerIcon: ({ tintColor }) => <Icon name="heart" solid={true} size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
WalletStack: { screen: walletStack, navigationOptions: {
|
||||
title: 'Wallet', drawerIcon: ({ tintColor }) => <Icon name="wallet" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
Rewards: { screen: RewardsPage, navigationOptions: {
|
||||
drawerIcon: ({ tintColor }) => <Icon name="award" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
MyLBRYStack: { screen: DownloadsPage, navigationOptions: {
|
||||
title: 'Library', drawerIcon: ({ tintColor }) => <Icon name="download" size={20} style={{ color: tintColor }} />
|
||||
}},
|
||||
Settings: { screen: SettingsPage, navigationOptions: {
|
||||
drawerLockMode: 'locked-closed',
|
||||
drawerIcon: ({ tintColor }) => <Icon name="cog" size={20} style={{ color: tintColor }} />
|
||||
@@ -161,12 +150,14 @@ const drawer = createDrawerNavigator({
|
||||
}, {
|
||||
drawerWidth: 300,
|
||||
headerMode: 'none',
|
||||
contentComponent: DrawerContent,
|
||||
contentOptions: {
|
||||
activeTintColor: Colors.LbryGreen
|
||||
activeTintColor: Colors.LbryGreen,
|
||||
labelStyle: discoverStyle.menuText
|
||||
}
|
||||
});
|
||||
|
||||
export const AppNavigator = new createStackNavigator({
|
||||
const mainStackNavigator = new createStackNavigator({
|
||||
FirstRun: {
|
||||
screen: FirstRunScreen,
|
||||
navigationOptions: {
|
||||
@@ -181,16 +172,25 @@ export const AppNavigator = new createStackNavigator({
|
||||
},
|
||||
Main: {
|
||||
screen: drawer
|
||||
},
|
||||
Verification: {
|
||||
screen: VerificationScreen,
|
||||
navigationOptions: {
|
||||
drawerLockMode: 'locked-closed'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
headerMode: 'none'
|
||||
});
|
||||
|
||||
|
||||
export const AppNavigator = mainStackNavigator;
|
||||
export const navigatorReducer = createNavigationReducer(AppNavigator);
|
||||
export const reactNavigationMiddleware = createReactNavigationReduxMiddleware(
|
||||
"root",
|
||||
state => state.nav,
|
||||
);
|
||||
const App = reduxifyNavigator(AppNavigator, "root");
|
||||
|
||||
const App = createReduxContainer(mainStackNavigator);
|
||||
const appMapStateToProps = (state) => ({
|
||||
state: state.nav,
|
||||
});
|
||||
@@ -201,15 +201,17 @@ class AppWithNavigationState extends React.Component {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.emailVerifyCheckInterval = null;
|
||||
this.state = {
|
||||
emailVerifyDone: false
|
||||
emailVerifyDone: false,
|
||||
verifyPending: false
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
AppState.addEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.addEventListener('hardwareBackPress', function() {
|
||||
const { dispatch, nav } = this.props;
|
||||
const { dispatch, nav, drawerStack } = this.props;
|
||||
// There should be a better way to check this
|
||||
if (nav.routes.length > 0) {
|
||||
if (nav.routes[0].routeName === 'Main') {
|
||||
@@ -218,7 +220,7 @@ class AppWithNavigationState extends React.Component {
|
||||
mainRoute.routes[0].index > 0 /* Discover stack index */ ||
|
||||
mainRoute.routes[4].index > 0 /* Wallet stack index */ ||
|
||||
mainRoute.index >= 5 /* Settings and About screens */) {
|
||||
dispatch(NavigationActions.back());
|
||||
dispatchNavigateBack(dispatch, nav, drawerStack);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -228,40 +230,57 @@ class AppWithNavigationState extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.emailVerifyCheckInterval = setInterval(() => this.checkEmailVerification(), 5000);
|
||||
Linking.addEventListener('url', this._handleUrl);
|
||||
}
|
||||
|
||||
checkEmailVerification = () => {
|
||||
const { dispatch } = this.props;
|
||||
AsyncStorage.getItem(Constants.KEY_EMAIL_VERIFY_PENDING).then(pending => {
|
||||
this.setState({ verifyPending: ('true' === pending) });
|
||||
if ('true' === pending) {
|
||||
dispatch(doUserCheckEmailVerified());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this._handleAppStateChange);
|
||||
BackHandler.removeEventListener('hardwareBackPress');
|
||||
Linking.removeEventListener('url', this._handleUrl);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
const { dispatch, user } = this.props;
|
||||
if (this.state.verifyPending && this.emailVerifyCheckInterval > 0 && user && user.has_verified_email) {
|
||||
clearInterval(this.emailVerifyCheckInterval);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'false');
|
||||
this.setState({ verifyPending: false });
|
||||
|
||||
ToastAndroid.show('Your email address was successfully verified.', ToastAndroid.LONG);
|
||||
|
||||
// upon successful email verification, do wallet sync (if password has been set)
|
||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(walletPassword => {
|
||||
if (walletPassword && walletPassword.trim().length > 0) {
|
||||
dispatch(doGetSync(walletPassword));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps) {
|
||||
const { dispatch } = this.props;
|
||||
const {
|
||||
notification,
|
||||
toast,
|
||||
emailToVerify,
|
||||
emailVerifyPending,
|
||||
emailVerifyErrorMessage,
|
||||
user
|
||||
} = nextProps;
|
||||
|
||||
if (notification) {
|
||||
const { displayType, message } = notification;
|
||||
if (toast) {
|
||||
const { message } = toast;
|
||||
let currentDisplayType;
|
||||
if (displayType && displayType.length) {
|
||||
for (let i = 0; i < displayType.length; i++) {
|
||||
const type = displayType[i];
|
||||
if (AppWithNavigationState.supportedDisplayTypes.indexOf(type) > -1) {
|
||||
currentDisplayType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (AppWithNavigationState.supportedDisplayTypes.indexOf(displayType) > -1) {
|
||||
currentDisplayType = displayType;
|
||||
}
|
||||
|
||||
if (!currentDisplayType && message) {
|
||||
// default to toast if no display type set and there is a message specified
|
||||
currentDisplayType = 'toast';
|
||||
@@ -271,7 +290,7 @@ class AppWithNavigationState extends React.Component {
|
||||
ToastAndroid.show(message, ToastAndroid.LONG);
|
||||
}
|
||||
|
||||
dispatch(doHideNotification());
|
||||
dispatch(doDismissToast());
|
||||
}
|
||||
|
||||
if (user &&
|
||||
@@ -286,8 +305,9 @@ class AppWithNavigationState extends React.Component {
|
||||
if (!emailVerifyErrorMessage) {
|
||||
AsyncStorage.removeItem(Constants.KEY_FIRST_RUN_EMAIL);
|
||||
}
|
||||
|
||||
AsyncStorage.removeItem(Constants.KEY_SHOULD_VERIFY_EMAIL);
|
||||
dispatch(doNotify({ message, displayType: ['toast'] }));
|
||||
dispatch(doToast({ message }));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -313,8 +333,6 @@ class AppWithNavigationState extends React.Component {
|
||||
}
|
||||
|
||||
if (AppState.currentState && AppState.currentState.match(/active/)) {
|
||||
// Cleanup blobs for completed files upon app resume to save space
|
||||
dispatch(doDeleteCompleteBlobs());
|
||||
if (backgroundPlayEnabled || NativeModules.BackgroundMedia) {
|
||||
NativeModules.BackgroundMedia.hidePlaybackNotification();
|
||||
}
|
||||
@@ -340,12 +358,11 @@ class AppWithNavigationState extends React.Component {
|
||||
} catch (error) {
|
||||
const message = 'Invalid Verification Token';
|
||||
dispatch(doUserEmailVerifyFailure(message));
|
||||
dispatch(doNotify({ message, displayType: ['toast'] }));
|
||||
dispatch(doToast({ message }));
|
||||
}
|
||||
} else {
|
||||
dispatch(doNotify({
|
||||
dispatch(doToast({
|
||||
message: 'Invalid Verification URI',
|
||||
displayType: ['toast'],
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
@@ -363,7 +380,8 @@ const mapStateToProps = state => ({
|
||||
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
||||
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
|
||||
nav: state.nav,
|
||||
notification: selectNotification(state),
|
||||
toast: selectToast(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
emailToVerify: selectEmailToVerify(state),
|
||||
emailVerifyPending: selectEmailVerifyIsPending(state),
|
||||
emailVerifyErrorMessage: selectEmailVerifyErrorMessage(state),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import Address from './view';
|
||||
|
||||
export default connect(null, {
|
||||
doNotify,
|
||||
doToast,
|
||||
})(Address);
|
||||
@@ -6,21 +6,20 @@ import walletStyle from '../../styles/wallet';
|
||||
|
||||
type Props = {
|
||||
address: string,
|
||||
doNotify: ({ message: string, displayType: Array<string> }) => void,
|
||||
doToast: ({ message: string }) => void,
|
||||
};
|
||||
|
||||
export default class Address extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { address, doNotify, style } = this.props;
|
||||
|
||||
const { address, doToast, style } = this.props;
|
||||
|
||||
return (
|
||||
<View style={[walletStyle.row, style]}>
|
||||
<Text selectable={true} numberOfLines={1} style={walletStyle.address}>{address || ''}</Text>
|
||||
<Button icon={'clipboard'} style={walletStyle.button} onPress={() => {
|
||||
Clipboard.setString(address);
|
||||
doNotify({
|
||||
doToast({
|
||||
message: 'Address copied',
|
||||
displayType: ['toast'],
|
||||
});
|
||||
}} />
|
||||
</View>
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class Button extends React.PureComponent {
|
||||
style,
|
||||
text,
|
||||
icon,
|
||||
iconColor,
|
||||
solid,
|
||||
theme,
|
||||
onPress,
|
||||
onLayout
|
||||
@@ -41,9 +43,14 @@ export default class Button extends React.PureComponent {
|
||||
textStyles.push(buttonStyle.textLight);
|
||||
}
|
||||
|
||||
let renderIcon = (<Icon name={icon} size={18} color={iconColor ? iconColor : ('light' === theme ? Colors.DarkGrey : Colors.White)} />);
|
||||
if (solid) {
|
||||
renderIcon = (<Icon name={icon} size={18} color={iconColor ? iconColor : ('light' === theme ? Colors.DarkGrey : Colors.White)} solid />);
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableOpacity disabled={disabled} style={styles} onPress={onPress} onLayout={onLayout}>
|
||||
{icon && <Icon name={icon} size={18} color={'light' === theme ? Colors.DarkGrey : Colors.White} />}
|
||||
{icon && renderIcon}
|
||||
{text && (text.trim().length > 0) && <Text style={textStyles}>{text}</Text>}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import CategoryList from './view';
|
||||
|
||||
export default connect(null, null)(CategoryList);
|
||||
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import { FlatList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import FileItem from '/component/fileItem';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
class CategoryList extends React.PureComponent {
|
||||
render() {
|
||||
const { category, categoryMap, navigation } = this.props;
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
style={discoverStyle.horizontalScrollContainer}
|
||||
contentContainerStyle={discoverStyle.horizontalScrollPadding}
|
||||
initialNumToRender={3}
|
||||
maxToRenderPerBatch={3}
|
||||
removeClippedSubviews={true}
|
||||
renderItem={ ({item}) => (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
compactView={false} />
|
||||
)
|
||||
}
|
||||
horizontal={true}
|
||||
showsHorizontalScrollIndicator={false}
|
||||
data={categoryMap[category]}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default CategoryList;
|
||||
@@ -0,0 +1,26 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import {
|
||||
doClaimRewardType,
|
||||
doClaimRewardClearError,
|
||||
makeSelectClaimRewardError,
|
||||
makeSelectIsRewardClaimPending,
|
||||
rewards as REWARD_TYPES
|
||||
} from 'lbryinc';
|
||||
import CustomRewardCard from './view';
|
||||
|
||||
const select = state => ({
|
||||
rewardIsPending: makeSelectIsRewardClaimPending()(state, {
|
||||
reward_type: REWARD_TYPES.TYPE_REWARD_CODE,
|
||||
}),
|
||||
error: makeSelectClaimRewardError()(state, { reward_type: REWARD_TYPES.TYPE_REWARD_CODE }),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, true)),
|
||||
clearError: reward => dispatch(doClaimRewardClearError(reward)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
submitRewardCode: code => dispatch(doClaimRewardType(REWARD_TYPES.TYPE_REWARD_CODE, { params: { code } }))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(CustomRewardCard);
|
||||
@@ -0,0 +1,88 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Keyboard, Text, TextInput, TouchableOpacity, View } from 'react-native';
|
||||
import Colors from '../../styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Button from '../button';
|
||||
import Link from '../link';
|
||||
import rewardStyle from '../../styles/reward';
|
||||
|
||||
class CustomRewardCard extends React.PureComponent<Props> {
|
||||
state = {
|
||||
claimStarted: false,
|
||||
rewardCode: ''
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { error, rewardIsPending } = nextProps;
|
||||
const { clearError, notify } = this.props;
|
||||
if (this.state.claimStarted && !rewardIsPending) {
|
||||
if (error && error.trim().length > 0) {
|
||||
notify({ message: error });
|
||||
} else {
|
||||
notify({ message: 'Reward successfully claimed!' });
|
||||
this.setState({ rewardCode: '' });
|
||||
}
|
||||
this.setState({ claimStarted: false });
|
||||
}
|
||||
}
|
||||
|
||||
onClaimPress = () => {
|
||||
const { canClaim, notify, showVerification, submitRewardCode } = this.props;
|
||||
const { rewardCode } = this.state;
|
||||
|
||||
Keyboard.dismiss();
|
||||
|
||||
if (!canClaim) {
|
||||
if (showVerification) {
|
||||
showVerification();
|
||||
}
|
||||
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rewardCode || rewardCode.trim().length === 0) {
|
||||
notify({ message: 'Please enter a reward code to claim.' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({ claimStarted: true }, () => {
|
||||
submitRewardCode(rewardCode);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { canClaim, rewardIsPending } = this.props;
|
||||
|
||||
return (
|
||||
<View style={[rewardStyle.rewardCard, rewardStyle.row]} >
|
||||
<View style={rewardStyle.leftCol}>
|
||||
{rewardIsPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
</View>
|
||||
<View style={rewardStyle.midCol}>
|
||||
<Text style={rewardStyle.rewardTitle}>Custom Code</Text>
|
||||
<Text style={rewardStyle.rewardDescription}>Are you a supermodel or rockstar that received a custom reward code? Claim it here.</Text>
|
||||
|
||||
<View>
|
||||
<TextInput style={rewardStyle.customCodeInput}
|
||||
placeholder={"0123abc"}
|
||||
onChangeText={text => this.setState({ rewardCode: text })}
|
||||
value={this.state.rewardCode} />
|
||||
<Button style={rewardStyle.redeemButton}
|
||||
text={"Redeem"}
|
||||
disabled={(!this.state.rewardCode || this.state.rewardCode.trim().length === 0 || rewardIsPending)}
|
||||
onPress={() => {
|
||||
if (!rewardIsPending) { this.onClaimPress(); }
|
||||
}} />
|
||||
</View>
|
||||
</View>
|
||||
<View style={rewardStyle.rightCol}>
|
||||
<Text style={rewardStyle.rewardAmount}>?</Text>
|
||||
<Text style={rewardStyle.rewardCurrency}>LBC</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default CustomRewardCard;
|
||||
@@ -0,0 +1,16 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectDateForUri } from 'lbry-redux';
|
||||
import DateTime from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
date: props.date || makeSelectDateForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchBlock: height => dispatch(doFetchBlock(height)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(DateTime);
|
||||
@@ -0,0 +1,55 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { View, Text } from 'react-native';
|
||||
|
||||
type Props = {
|
||||
date?: number,
|
||||
timeAgo?: boolean,
|
||||
formatOptions: {},
|
||||
show?: string,
|
||||
};
|
||||
|
||||
class DateTime extends React.PureComponent<Props> {
|
||||
static SHOW_DATE = 'date';
|
||||
static SHOW_TIME = 'time';
|
||||
static SHOW_BOTH = 'both';
|
||||
|
||||
static defaultProps = {
|
||||
formatOptions: {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
},
|
||||
};
|
||||
|
||||
render() {
|
||||
const { date, formatOptions, timeAgo, style, textStyle } = this.props;
|
||||
const show = this.props.show || DateTime.SHOW_BOTH;
|
||||
const locale = 'en-US'; // default to en-US until we get a working i18n module for RN
|
||||
|
||||
if (timeAgo) {
|
||||
return date ? <View style={style}><Text style={textStyle}>{moment(date).from(moment())}</Text></View> : null;
|
||||
}
|
||||
|
||||
// TODO: formatOptions not working as expected in RN
|
||||
// date.toLocaleDateString([locale, 'en-US'], formatOptions)}
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<Text style={textStyle}>
|
||||
{date &&
|
||||
(show === DateTime.SHOW_BOTH || show === DateTime.SHOW_DATE) &&
|
||||
moment(date).format('MMMM D, YYYY')}
|
||||
{show === DateTime.SHOW_BOTH && ' '}
|
||||
{date &&
|
||||
(show === DateTime.SHOW_BOTH || show === DateTime.SHOW_TIME) &&
|
||||
date.toLocaleTimeString()}
|
||||
{!date && '...'}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default DateTime;
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import DrawerContent from './view';
|
||||
|
||||
export default connect()(DrawerContent);
|
||||
@@ -0,0 +1,38 @@
|
||||
import React from 'react';
|
||||
import { DrawerItems, SafeAreaView } from 'react-navigation';
|
||||
import { ScrollView } from 'react-native';
|
||||
import Constants from 'constants';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
class DrawerContent extends React.PureComponent {
|
||||
render() {
|
||||
const props = this.props;
|
||||
const { navigation, onItemPress } = props;
|
||||
|
||||
return (
|
||||
<ScrollView>
|
||||
<SafeAreaView style={discoverStyle.drawerContentContainer} forceInset={{ top: 'always', horizontal: 'never' }}>
|
||||
<DrawerItems
|
||||
{...props}
|
||||
onItemPress={(route) => {
|
||||
const { routeName } = route.route;
|
||||
if (Constants.FULL_ROUTE_NAME_DISCOVER === routeName) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_DISCOVER });
|
||||
return;
|
||||
}
|
||||
|
||||
if (Constants.FULL_ROUTE_NAME_WALLET === routeName) {
|
||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_WALLET });
|
||||
return;
|
||||
}
|
||||
|
||||
onItemPress(route);
|
||||
}}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default DrawerContent;
|
||||
@@ -1,22 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doUserEmailNew,
|
||||
selectEmailNewErrorMessage,
|
||||
selectEmailNewIsPending,
|
||||
selectEmailToVerify
|
||||
} from 'lbryinc';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import EmailRewardSubcard from './view';
|
||||
|
||||
const select = state => ({
|
||||
emailToVerify: selectEmailToVerify(state),
|
||||
emailNewErrorMessage: selectEmailNewErrorMessage(state),
|
||||
emailNewPending: selectEmailNewIsPending(state)
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
notify: data => dispatch(doNotify(data))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(EmailRewardSubcard);
|
||||
@@ -1,98 +0,0 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
View
|
||||
} from 'react-native';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Button from '../button';
|
||||
import Colors from '../../styles/colors';
|
||||
import Constants from '../../constants';
|
||||
import Link from '../link';
|
||||
import rewardStyle from '../../styles/reward';
|
||||
|
||||
class EmailRewardSubcard extends React.PureComponent {
|
||||
state = {
|
||||
email: null,
|
||||
verfiyStarted: false
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { emailToVerify } = this.props;
|
||||
AsyncStorage.getItem(Constants.KEY_FIRST_RUN_EMAIL).then(email => {
|
||||
if (email && email.trim().length > 0) {
|
||||
this.setState({ email });
|
||||
} else {
|
||||
this.setState({ email: emailToVerify });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { emailNewErrorMessage, emailNewPending } = nextProps;
|
||||
const { notify } = this.props;
|
||||
|
||||
if (this.state.verifyStarted && !emailNewPending) {
|
||||
if (emailNewErrorMessage) {
|
||||
notify({ message: String(emailNewErrorMessage), displayType: ['toast']});
|
||||
this.setState({ verifyStarted: false });
|
||||
} else {
|
||||
notify({
|
||||
message: 'Please follow the instructions in the email sent to your address to continue.',
|
||||
displayType: ['toast']
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleChangeText = (text) => {
|
||||
// save the value to the state email
|
||||
this.setState({ email: text });
|
||||
AsyncStorage.setItem(Constants.KEY_FIRST_RUN_EMAIL, text);
|
||||
}
|
||||
|
||||
onSendVerificationPressed = () => {
|
||||
if (this.state.verifyStarted) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { addUserEmail, notify } = this.props;
|
||||
const { email } = this.state;
|
||||
if (!email || email.trim().length === 0 || email.indexOf('@') === -1) {
|
||||
return notify({
|
||||
message: 'Please provide a valid email address to continue.',
|
||||
displayType: ['toast'],
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({ verifyStarted: true });
|
||||
addUserEmail(email);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { emailNewPending } = this.props;
|
||||
|
||||
return (
|
||||
<View style={rewardStyle.subcard}>
|
||||
<Text style={rewardStyle.subtitle}>Pending action: Verify Email</Text>
|
||||
<Text style={rewardStyle.subcardText}>Please provide an email address to verify. If you received a link previously, please follow the instructions in the email to complete verification.</Text>
|
||||
<TextInput style={rewardStyle.subcardTextInput}
|
||||
placeholder="you@example.com"
|
||||
underlineColorAndroid="transparent"
|
||||
value={this.state.email}
|
||||
onChangeText={text => this.handleChangeText(text)} />
|
||||
{!this.state.verifyStarted && <Button style={rewardStyle.actionButton}
|
||||
text={"Send verification email"}
|
||||
onPress={this.onSendVerificationPressed} />}
|
||||
{this.state.verifyStarted && emailNewPending &&
|
||||
<ActivityIndicator size={"small"} color={Colors.LbryGreen} style={rewardStyle.loading} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default EmailRewardSubcard;
|
||||
@@ -1,12 +1,12 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchCostInfoForUri,
|
||||
doPurchaseUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectDownloadingForUri,
|
||||
makeSelectLoadingForUri,
|
||||
makeSelectCostInfoForUri
|
||||
} from 'lbry-redux';
|
||||
import { doPurchaseUri, doStartDownload } from '../../redux/actions/file';
|
||||
import { doFetchCostInfoForUri, makeSelectCostInfoForUri } from 'lbryinc';
|
||||
import { doStartDownload } from 'redux/actions/file';
|
||||
import FileDownloadButton from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -17,7 +17,7 @@ const select = (state, props) => ({
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
purchaseUri: (uri, failureCallback) => dispatch(doPurchaseUri(uri, null, failureCallback)),
|
||||
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
|
||||
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
|
||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
|
||||
import Button from '../button';
|
||||
import fileDownloadButtonStyle from '../../styles/fileDownloadButton';
|
||||
import fileDownloadButtonStyle from 'styles/fileDownloadButton';
|
||||
|
||||
class FileDownloadButton extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
@@ -13,7 +13,7 @@ class FileDownloadButton extends React.PureComponent {
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
//this.checkAvailability(nextProps.uri);
|
||||
this.restartDownload(nextProps);
|
||||
//this.restartDownload(nextProps);
|
||||
}
|
||||
|
||||
restartDownload(props) {
|
||||
@@ -38,13 +38,14 @@ class FileDownloadButton extends React.PureComponent {
|
||||
purchaseUri,
|
||||
costInfo,
|
||||
isPlayable,
|
||||
isViewable,
|
||||
onPlay,
|
||||
onView,
|
||||
loading,
|
||||
doPause,
|
||||
style,
|
||||
openFile,
|
||||
onButtonLayout,
|
||||
onStartDownloadFailed
|
||||
} = this.props;
|
||||
|
||||
if ((fileInfo && !fileInfo.stopped) || loading || downloading) {
|
||||
@@ -58,7 +59,7 @@ class FileDownloadButton extends React.PureComponent {
|
||||
<Text style={fileDownloadButtonStyle.text}>{label}</Text>
|
||||
</View>
|
||||
);
|
||||
} else if (fileInfo === null && !downloading) {
|
||||
} else if (!fileInfo && !downloading) {
|
||||
if (!costInfo) {
|
||||
return (
|
||||
<View style={[style, fileDownloadButtonStyle.container]}>
|
||||
@@ -68,23 +69,29 @@ class FileDownloadButton extends React.PureComponent {
|
||||
}
|
||||
return (
|
||||
<Button icon={isPlayable ? 'play' : null}
|
||||
text={isPlayable ? 'Play' : 'Download'}
|
||||
text={(isPlayable ? 'Play' : (isViewable ? 'View' : 'Download'))}
|
||||
onLayout={onButtonLayout}
|
||||
style={[style, fileDownloadButtonStyle.container]} onPress={() => {
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Purchase Uri', { Uri: uri });
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('purchase_uri', { uri: uri });
|
||||
}
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
purchaseUri(uri, onStartDownloadFailed);
|
||||
if (isPlayable && onPlay) {
|
||||
this.props.onPlay();
|
||||
}
|
||||
if (isViewable && onView) {
|
||||
this.props.onView();
|
||||
}
|
||||
}} />
|
||||
);
|
||||
} else if (fileInfo && fileInfo.download_path) {
|
||||
return (
|
||||
<TouchableOpacity onLayout={onButtonLayout}
|
||||
style={[style, fileDownloadButtonStyle.container]} onPress={openFile}>
|
||||
<Text style={fileDownloadButtonStyle.text}>Open</Text>
|
||||
<Text style={fileDownloadButtonStyle.text}>{isViewable ? 'View' : 'Open'}</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ import {
|
||||
makeSelectClaimForUri,
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectClaimIsNsfw
|
||||
} from 'lbry-redux';
|
||||
import { selectRewardContentClaimIds } from 'lbryinc';
|
||||
import { selectShowNsfw } from '../../redux/selectors/settings';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -16,7 +19,10 @@ const select = (state, props) => ({
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
obscureNsfw: !selectShowNsfw(state)
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
nsfw: makeSelectClaimIsNsfw(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
|
||||
@@ -2,14 +2,15 @@ import React from 'react';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { NavigationActions } from 'react-navigation';
|
||||
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
|
||||
import { navigateToUri } from '../../utils/helper';
|
||||
import Colors from '../../styles/colors';
|
||||
import FileItemMedia from '../fileItemMedia';
|
||||
import FilePrice from '../filePrice';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import DateTime from 'component/dateTime';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
import FilePrice from 'component/filePrice';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from '../link';
|
||||
import NsfwOverlay from '../nsfwOverlay';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import Link from 'component/link';
|
||||
import NsfwOverlay from 'component/nsfwOverlay';
|
||||
import discoverStyle from 'styles/discover';
|
||||
|
||||
class FileItem extends React.PureComponent {
|
||||
constructor(props) {
|
||||
@@ -32,50 +33,67 @@ class FileItem extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
navigateToFileUri = () => {
|
||||
const { navigation, uri } = this.props;
|
||||
const normalizedUri = normalizeURI(uri);
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('explore_click', { uri: normalizedUri });
|
||||
}
|
||||
navigateToUri(navigation, normalizedUri);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
claim,
|
||||
title,
|
||||
thumbnail,
|
||||
fileInfo,
|
||||
metadata,
|
||||
isResolvingUri,
|
||||
rewardedContentClaimIds,
|
||||
style,
|
||||
mediaStyle,
|
||||
navigation
|
||||
navigation,
|
||||
showDetails,
|
||||
compactView,
|
||||
titleBeforeThumbnail
|
||||
} = this.props;
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
const title = metadata && metadata.title ? metadata.title : uri;
|
||||
const thumbnail = metadata && metadata.thumbnail ? metadata.thumbnail : null;
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const isRewardContent = claim && rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const channelName = claim ? claim.channel_name : null;
|
||||
const channelClaimId = claim && claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
const fullChannelUri = channelClaimId ? `${channelName}#${channelClaimId}` : channelName;
|
||||
const height = claim ? claim.height : null;
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
<TouchableOpacity style={discoverStyle.container} onPress={() => {
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Discover Tap', { Uri: uri });
|
||||
}
|
||||
navigateToUri(navigation, uri);
|
||||
}
|
||||
}>
|
||||
<TouchableOpacity style={discoverStyle.container} onPress={this.navigateToFileUri}>
|
||||
{!compactView && titleBeforeThumbnail && <Text numberOfLines={1} style={[discoverStyle.fileItemName, discoverStyle.rewardTitle]}>{title}</Text>}
|
||||
<FileItemMedia title={title}
|
||||
thumbnail={thumbnail}
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
resizeMode="cover"
|
||||
isResolvingUri={isResolvingUri}
|
||||
style={mediaStyle} />
|
||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />
|
||||
<View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
|
||||
<Text style={[discoverStyle.fileItemName, discoverStyle.rewardTitle]}>{title}</Text>
|
||||
{isRewardContent && <Icon style={discoverStyle.rewardIcon} name="award" size={20} />}
|
||||
</View>
|
||||
{channelName &&
|
||||
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
||||
const channelUri = normalizeURI(channelName);
|
||||
navigateToUri(navigation, channelUri);
|
||||
}} />}
|
||||
|
||||
{(!compactView && fileInfo && fileInfo.completed && fileInfo.download_path) &&
|
||||
<Icon style={discoverStyle.downloadedIcon} solid={true} color={Colors.NextLbryGreen} name={"folder"} size={16} />}
|
||||
{(!compactView && (!fileInfo || !fileInfo.completed || !fileInfo.download_path)) &&
|
||||
<FilePrice uri={uri} style={discoverStyle.filePriceContainer} textStyle={discoverStyle.filePriceText} />}
|
||||
{!compactView && <View style={isRewardContent ? discoverStyle.rewardTitleContainer : null}>
|
||||
<Text numberOfLines={1} style={[discoverStyle.fileItemName, discoverStyle.rewardTitle]}>{title}</Text>
|
||||
{isRewardContent && <Icon style={discoverStyle.rewardIcon} name="award" size={14} />}
|
||||
</View>}
|
||||
{(!compactView && showDetails) &&
|
||||
<View style={discoverStyle.detailsRow}>
|
||||
{channelName &&
|
||||
<Link style={discoverStyle.channelName} text={channelName} onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />}
|
||||
<DateTime style={discoverStyle.dateTime} textStyle={discoverStyle.dateTimeText} timeAgo uri={uri} />
|
||||
</View>}
|
||||
</TouchableOpacity>
|
||||
{obscureNsfw && <NsfwOverlay onPress={() => navigation.navigate({ routeName: 'Settings', key: 'settingsPage' })} />}
|
||||
</View>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Image, Text, View } from 'react-native';
|
||||
import Colors from '../../styles/colors';
|
||||
import Colors from 'styles/colors';
|
||||
import FastImage from 'react-native-fast-image'
|
||||
import fileItemMediaStyle from '../../styles/fileItemMedia';
|
||||
import fileItemMediaStyle from 'styles/fileItemMedia';
|
||||
|
||||
class FileItemMedia extends React.PureComponent {
|
||||
static AUTO_THUMB_STYLES = [
|
||||
@@ -45,11 +45,23 @@ class FileItemMedia extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
isThumbnailValid = (thumbnail) => {
|
||||
if (!thumbnail || ((typeof thumbnail) !== 'string')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (thumbnail.substring(0, 7) != 'http://' && thumbnail.substring(0, 8) != 'https://') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
render() {
|
||||
let style = this.props.style;
|
||||
const { blurRadius, isResolvingUri, thumbnail, title, resizeMode } = this.props;
|
||||
const atStyle = this.state.autoThumbStyle;
|
||||
if (thumbnail && ((typeof thumbnail) === 'string') && !this.state.imageLoadFailed) {
|
||||
if (this.isThumbnailValid(thumbnail) && !this.state.imageLoadFailed) {
|
||||
if (style == null) {
|
||||
style = fileItemMediaStyle.thumbnail;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import * as React from 'react';
|
||||
import { buildURI } from 'lbry-redux';
|
||||
import { FlatList } from 'react-native';
|
||||
import FileItem from '../fileItem';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import FileItem from 'component/fileItem';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
|
||||
// In the future, all Flow types need to be specified in a common source (lbry-redux, perhaps?)
|
||||
type FileInfo = {
|
||||
@@ -145,7 +145,15 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
sortFunctions: {};
|
||||
|
||||
render() {
|
||||
const { fileInfos, hideFilter, checkPending, navigation, style } = this.props;
|
||||
const {
|
||||
contentContainerStyle,
|
||||
fileInfos,
|
||||
hideFilter,
|
||||
checkPending,
|
||||
navigation,
|
||||
onEndReached,
|
||||
style
|
||||
} = this.props;
|
||||
const { sortBy } = this.state;
|
||||
const items = [];
|
||||
|
||||
@@ -166,17 +174,21 @@ class FileList extends React.PureComponent<Props, State> {
|
||||
|
||||
items.push(uri);
|
||||
});
|
||||
|
||||
|
||||
return (
|
||||
<FlatList
|
||||
style={style}
|
||||
contentContainerStyle={contentContainerStyle}
|
||||
data={items}
|
||||
onEndReached={onEndReached}
|
||||
keyExtractor={(item, index) => item}
|
||||
renderItem={({item}) => (
|
||||
<FileItem style={discoverStyle.fileItem}
|
||||
<FileItem style={fileListStyle.fileItem}
|
||||
uri={item}
|
||||
navigation={navigation} />
|
||||
)} />
|
||||
navigation={navigation}
|
||||
showDetails={true}
|
||||
compactView={false} />
|
||||
)} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import {
|
||||
makeSelectMetadataForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectTitleForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from '../../redux/selectors/settings';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import FileListItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
@@ -15,7 +17,9 @@ const select = (state, props) => ({
|
||||
isDownloaded: !!makeSelectFileInfoForUri(props.uri)(state),
|
||||
metadata: makeSelectMetadataForUri(props.uri)(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(props.uri)(state),
|
||||
obscureNsfw: !selectShowNsfw(state)
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
|
||||
@@ -3,17 +3,19 @@ import { normalizeURI, parseURI } from 'lbry-redux';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Platform,
|
||||
ProgressBarAndroid,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { navigateToUri, formatBytes } from '../../utils/helper';
|
||||
import Colors from '../../styles/colors';
|
||||
import FileItemMedia from '../fileItemMedia';
|
||||
import Link from '../../component/link';
|
||||
import NsfwOverlay from '../../component/nsfwOverlay';
|
||||
import fileListStyle from '../../styles/fileList';
|
||||
import { navigateToUri, formatBytes } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import DateTime from 'component/dateTime';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import Link from 'component/link';
|
||||
import NsfwOverlay from 'component/nsfwOverlay';
|
||||
import ProgressBar from 'component/progressBar';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
|
||||
class FileListItem extends React.PureComponent {
|
||||
getStorageForFileInfo = (fileInfo) => {
|
||||
@@ -50,23 +52,31 @@ class FileListItem extends React.PureComponent {
|
||||
claim,
|
||||
fileInfo,
|
||||
metadata,
|
||||
featuredResult,
|
||||
isResolvingUri,
|
||||
isDownloaded,
|
||||
style,
|
||||
onPress,
|
||||
navigation
|
||||
navigation,
|
||||
thumbnail,
|
||||
title
|
||||
} = this.props;
|
||||
|
||||
const uri = normalizeURI(this.props.uri);
|
||||
const obscureNsfw = this.props.obscureNsfw && metadata && metadata.nsfw;
|
||||
const isResolving = !fileInfo && isResolvingUri;
|
||||
const title = fileInfo ? fileInfo.metadata.title : metadata && metadata.title ? metadata.title : parseURI(uri).contentName;
|
||||
|
||||
let name;
|
||||
let channel;
|
||||
let name, channel, height, channelClaimId, fullChannelUri;
|
||||
if (claim) {
|
||||
name = claim.name;
|
||||
channel = claim.channel_name;
|
||||
height = claim.height;
|
||||
channelClaimId = claim.value && claim.value.publisherSignature && claim.value.publisherSignature.certificateId;
|
||||
fullChannelUri = channelClaimId ? `${channel}#${channelClaimId}` : channel;
|
||||
}
|
||||
|
||||
if (featuredResult && !isResolvingUri && !claim && !title && !name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -76,31 +86,41 @@ class FileListItem extends React.PureComponent {
|
||||
blurRadius={obscureNsfw ? 15 : 0}
|
||||
resizeMode="cover"
|
||||
title={(title || name)}
|
||||
thumbnail={metadata ? metadata.thumbnail : null} />
|
||||
thumbnail={thumbnail} />
|
||||
{(fileInfo && fileInfo.completed && fileInfo.download_path) &&
|
||||
<Icon style={fileListStyle.downloadedIcon} solid={true} color={Colors.NextLbryGreen} name={"folder"} size={16} />}
|
||||
<View style={fileListStyle.detailsContainer}>
|
||||
{featuredResult && <Text style={fileListStyle.featuredUri} numberOfLines={1}>{uri}</Text>}
|
||||
|
||||
{!title && !name && !channel && isResolving && (
|
||||
<View>
|
||||
{(!title && !name) && <Text style={fileListStyle.uri}>{uri}</Text>}
|
||||
{(!title && !name) && <View style={fileListStyle.row}>
|
||||
<ActivityIndicator size={"small"} color={Colors.LbryGreen} />
|
||||
<ActivityIndicator size={"small"} color={featuredResult ? Colors.White : Colors.LbryGreen} />
|
||||
</View>}
|
||||
</View>)}
|
||||
|
||||
{(title || name) && <Text style={fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
|
||||
{(title || name) && <Text style={featuredResult ? fileListStyle.featuredTitle : fileListStyle.title}>{this.formatTitle(title) || this.formatTitle(name)}</Text>}
|
||||
{channel &&
|
||||
<Link style={fileListStyle.publisher} text={channel} onPress={() => {
|
||||
const channelUri = normalizeURI(channel);
|
||||
navigateToUri(navigation, channelUri);
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />}
|
||||
|
||||
{fileInfo &&
|
||||
<View style={fileListStyle.info}>
|
||||
{(fileInfo && !isNaN(fileInfo.written_bytes) && fileInfo.written_bytes > 0) &&
|
||||
<Text style={fileListStyle.infoText}>{this.getStorageForFileInfo(fileInfo)}</Text>}
|
||||
<DateTime style={fileListStyle.publishInfo} textStyle={fileListStyle.infoText} timeAgo uri={uri} />
|
||||
</View>
|
||||
|
||||
{(fileInfo && fileInfo.download_path) &&
|
||||
<View style={fileListStyle.downloadInfo}>
|
||||
<Text style={fileListStyle.downloadStorage}>{this.getStorageForFileInfo(fileInfo)}</Text>
|
||||
{!fileInfo.completed &&
|
||||
<View style={fileListStyle.progress}>
|
||||
<View style={[fileListStyle.progressCompleted, { flex: this.getDownloadProgress(fileInfo) } ]} />
|
||||
<View style={[fileListStyle.progressRemaining, { flex: (100 - this.getDownloadProgress(fileInfo)) } ]} />
|
||||
</View>}
|
||||
<ProgressBar
|
||||
borderRadius={3}
|
||||
color={Colors.NextLbryGreen}
|
||||
height={3}
|
||||
style={fileListStyle.progress}
|
||||
progress={this.getDownloadProgress(fileInfo)} />}
|
||||
</View>
|
||||
}
|
||||
</View>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchCostInfoForUri,
|
||||
makeSelectCostInfoForUri,
|
||||
makeSelectFetchingCostInfoForUri,
|
||||
makeSelectClaimForUri
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectClaimForUri } from 'lbry-redux';
|
||||
import { doFetchCostInfoForUri, makeSelectCostInfoForUri, makeSelectFetchingCostInfoForUri } from 'lbryinc';
|
||||
import FilePrice from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
|
||||
@@ -108,7 +108,7 @@ class FilePrice extends React.PureComponent {
|
||||
<CreditAmount
|
||||
style={textStyle}
|
||||
label={false}
|
||||
amount={costInfo.cost}
|
||||
amount={parseFloat(costInfo.cost)}
|
||||
isEstimate={isEstimate}
|
||||
showFree
|
||||
showFullPrice={showFullPrice}>???</CreditAmount>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import FileRewardsDriver from './view';
|
||||
|
||||
export default connect()(FileRewardsDriver);
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import filePageStyle from 'styles/filePage';
|
||||
|
||||
class FileRewardsDriver extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={filePageStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
|
||||
<Icon name="award" size={16} style={filePageStyle.rewardIcon} />
|
||||
<Text style={filePageStyle.rewardDriverText}>Earn some credits to access this content.</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default FileRewardsDriver;
|
||||
@@ -1,9 +1,14 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { selectBalance } from 'lbry-redux';
|
||||
import { selectUnclaimedRewardValue } from 'lbryinc';
|
||||
import Constants from 'constants';
|
||||
import FloatingWalletBalance from './view';
|
||||
|
||||
const select = state => ({
|
||||
balance: selectBalance(state),
|
||||
unclaimedRewardAmount: selectUnclaimedRewardValue(state),
|
||||
rewardsNotInterested: makeSelectClientSetting(Constants.SETTING_REWARDS_NOT_INTERESTED)(state),
|
||||
});
|
||||
|
||||
export default connect(select, null)(FloatingWalletBalance);
|
||||
@@ -2,10 +2,11 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Text, TouchableOpacity, View } from 'react-native';
|
||||
import { formatCredits } from 'lbry-redux'
|
||||
import Address from '../address';
|
||||
import Button from '../button';
|
||||
import Colors from '../../styles/colors';
|
||||
import floatingButtonStyle from '../../styles/floatingButton';
|
||||
import Address from 'component/address';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import floatingButtonStyle from 'styles/floatingButton';
|
||||
|
||||
type Props = {
|
||||
balance: number,
|
||||
@@ -13,16 +14,23 @@ type Props = {
|
||||
|
||||
class FloatingWalletBalance extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { balance, navigation } = this.props;
|
||||
const { balance, navigation, rewardsNotInterested, unclaimedRewardAmount } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={[floatingButtonStyle.container, floatingButtonStyle.bottomRight]}
|
||||
onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}>
|
||||
{isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />}
|
||||
<Text style={floatingButtonStyle.text}>
|
||||
{(balance || balance === 0) && (formatCredits(balance, 2) + ' LBC')}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
<View style={[floatingButtonStyle.view, floatingButtonStyle.bottomRight]}>
|
||||
{(!rewardsNotInterested && unclaimedRewardAmount > 0) &&
|
||||
<TouchableOpacity style={floatingButtonStyle.pendingContainer}
|
||||
onPress={() => navigation && navigation.navigate({ routeName: 'Rewards' })} >
|
||||
<Icon name="award" size={18} style={floatingButtonStyle.rewardIcon} />
|
||||
<Text style={floatingButtonStyle.text}>{unclaimedRewardAmount}</Text>
|
||||
</TouchableOpacity>}
|
||||
<TouchableOpacity style={floatingButtonStyle.container}
|
||||
onPress={() => navigation && navigation.navigate({ routeName: 'WalletStack' })}>
|
||||
{isNaN(balance) && <ActivityIndicator size="small" color={Colors.White} />}
|
||||
{(!isNaN(balance) || balance === 0) && (
|
||||
<Text style={floatingButtonStyle.text}>{(formatCredits(parseFloat(balance), 2) + ' LBC')}</Text>)}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import Link from './view';
|
||||
|
||||
const perform = dispatch => ({
|
||||
notify: (data) => dispatch(doNotify(data))
|
||||
notify: (data) => dispatch(doToast(data))
|
||||
});
|
||||
|
||||
export default connect(null, perform)(Link);
|
||||
@@ -21,7 +21,7 @@ export default class Link extends React.PureComponent {
|
||||
Linking.openURL(href)
|
||||
.then(() => setTimeout(() => { this.setState({ tappedStyle: false }); }, 2000))
|
||||
.catch(err => {
|
||||
notify({ message: error, displayType: ['toast']})
|
||||
notify({ message: error, isError: true })
|
||||
this.setState({tappedStyle: false})
|
||||
}
|
||||
);
|
||||
@@ -35,6 +35,8 @@ export default class Link extends React.PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
ellipsizeMode,
|
||||
numberOfLines,
|
||||
onPress,
|
||||
style,
|
||||
text
|
||||
@@ -54,7 +56,13 @@ export default class Link extends React.PureComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<Text style={styles} onPress={onPress ? onPress : this.handlePress}>{text}</Text>
|
||||
<Text
|
||||
style={styles}
|
||||
numberOfLines={numberOfLines}
|
||||
ellipsizeMode={ellipsizeMode}
|
||||
onPress={onPress ? onPress : this.handlePress}>
|
||||
{text}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,10 +1,18 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { SETTINGS } from 'lbry-redux';
|
||||
import { makeSelectClientSetting } from '../../redux/selectors/settings';
|
||||
import { SETTINGS, savePosition } from 'lbry-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import { doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectIsPlayerVisible } from 'redux/selectors/drawer';
|
||||
import MediaPlayer from './view';
|
||||
|
||||
const select = state => ({
|
||||
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
||||
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
|
||||
isPlayerVisible: selectIsPlayerVisible(state),
|
||||
});
|
||||
|
||||
export default connect(select, null)(MediaPlayer);
|
||||
const perform = dispatch => ({
|
||||
savePosition: (claimId, outpoint, position) => dispatch(savePosition(claimId, outpoint, position)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(MediaPlayer);
|
||||
@@ -1,6 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import {
|
||||
AppState,
|
||||
ActivityIndicator,
|
||||
DeviceEventEmitter,
|
||||
NativeModules,
|
||||
PanResponder,
|
||||
@@ -9,10 +11,14 @@ import {
|
||||
ScrollView,
|
||||
TouchableOpacity
|
||||
} from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import FastImage from 'react-native-fast-image'
|
||||
import Video from 'react-native-video';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import FileItemMedia from '../fileItemMedia';
|
||||
import mediaPlayerStyle from '../../styles/mediaPlayer';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
import mediaPlayerStyle from 'styles/mediaPlayer';
|
||||
|
||||
const positionSaveInterval = 10
|
||||
|
||||
class MediaPlayer extends React.PureComponent {
|
||||
static ControlsTimeout = 3000;
|
||||
@@ -30,7 +36,9 @@ class MediaPlayer extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
encodedFilePath: null,
|
||||
buffering: false,
|
||||
backgroundPlayEnabled: false,
|
||||
autoPaused: false,
|
||||
rate: 1,
|
||||
volume: 1,
|
||||
muted: false,
|
||||
@@ -80,13 +88,26 @@ class MediaPlayer extends React.PureComponent {
|
||||
this.setState({
|
||||
duration: data.duration
|
||||
});
|
||||
|
||||
const { position } = this.props;
|
||||
if (!isNaN(parseFloat(position)) && position > 0) {
|
||||
this.video.seek(position);
|
||||
this.setState({ currentTime: position }, () => this.setSeekerPosition(this.calculateSeekerPosition()));
|
||||
}
|
||||
|
||||
if (this.props.onMediaLoaded) {
|
||||
this.props.onMediaLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
onProgress = (data) => {
|
||||
this.setState({ currentTime: data.currentTime });
|
||||
const { savePosition, claim } = this.props;
|
||||
|
||||
this.setState({ buffering: false, currentTime: data.currentTime });
|
||||
if (data.currentTime > 0 && Math.floor(data.currentTime) % positionSaveInterval === 0) {
|
||||
const { claim_id: claimId, txid, nout } = claim;
|
||||
savePosition(claimId, `${txid}:${nout}`, data.currentTime);
|
||||
}
|
||||
|
||||
if (!this.state.seeking) {
|
||||
this.setSeekerPosition(this.calculateSeekerPosition());
|
||||
@@ -97,6 +118,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
this.props.onPlaybackStarted();
|
||||
}
|
||||
this.setState({ firstPlay: false });
|
||||
|
||||
this.hidePlayerControls();
|
||||
}
|
||||
}
|
||||
@@ -129,6 +151,11 @@ class MediaPlayer extends React.PureComponent {
|
||||
}
|
||||
|
||||
togglePlayerControls = () => {
|
||||
const { setPlayerVisible, isPlayerVisible } = this.props;
|
||||
if (!isPlayerVisible) {
|
||||
setPlayerVisible();
|
||||
}
|
||||
|
||||
if (this.state.areControlsVisible) {
|
||||
this.manualHidePlayerControls();
|
||||
} else {
|
||||
@@ -138,7 +165,14 @@ class MediaPlayer extends React.PureComponent {
|
||||
|
||||
togglePlay = () => {
|
||||
this.showPlayerControls();
|
||||
this.setState({ paused: !this.state.paused });
|
||||
this.setState({ paused: !this.state.paused }, this.handlePausedState);
|
||||
}
|
||||
|
||||
handlePausedState = () => {
|
||||
if (!this.state.paused) {
|
||||
// onProgress will automatically clear this, so it's fine
|
||||
this.setState({ buffering: true });
|
||||
}
|
||||
}
|
||||
|
||||
toggleFullscreenMode = () => {
|
||||
@@ -153,6 +187,9 @@ class MediaPlayer extends React.PureComponent {
|
||||
|
||||
onEnd = () => {
|
||||
this.setState({ paused: true });
|
||||
if (this.props.onPlaybackFinished) {
|
||||
this.props.onPlaybackFinished();
|
||||
}
|
||||
this.video.seek(0);
|
||||
}
|
||||
|
||||
@@ -203,7 +240,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
onPanResponderRelease: (evt, gestureState) => {
|
||||
const time = this.getCurrentTimeForSeekerPosition();
|
||||
if (time >= this.state.duration) {
|
||||
this.setState({ paused: true });
|
||||
this.setState({ paused: true }, this.handlePausedState);
|
||||
this.onEnd();
|
||||
} else {
|
||||
this.seekTo(time);
|
||||
@@ -237,18 +274,29 @@ class MediaPlayer extends React.PureComponent {
|
||||
this.initSeeker();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { isPlayerVisible } = nextProps;
|
||||
if (!isPlayerVisible && !this.state.backgroundPlayEnabled) {
|
||||
// force pause if the player is not visible and background play is not enabled
|
||||
this.setState({ paused: true });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { assignPlayer } = this.props;
|
||||
const { assignPlayer, backgroundPlayEnabled } = this.props;
|
||||
if (assignPlayer) {
|
||||
assignPlayer(this);
|
||||
}
|
||||
|
||||
this.setState({ backgroundPlayEnabled: !!backgroundPlayEnabled });
|
||||
this.setSeekerPosition(this.calculateSeekerPosition());
|
||||
AppState.addEventListener('change', this.handleAppStateChange);
|
||||
DeviceEventEmitter.addListener('onBackgroundPlayPressed', this.play);
|
||||
DeviceEventEmitter.addListener('onBackgroundPausePressed', this.pause);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
AppState.removeEventListener('change', this.handleAppStateChange);
|
||||
DeviceEventEmitter.removeListener('onBackgroundPlayPressed', this.play);
|
||||
DeviceEventEmitter.removeListener('onBackgroundPausePressed', this.pause);
|
||||
this.clearControlsTimeout();
|
||||
@@ -259,6 +307,26 @@ class MediaPlayer extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handleAppStateChange = () => {
|
||||
if (AppState.currentState && AppState.currentState.match(/inactive|background/)) {
|
||||
if (!this.state.backgroundPlayEnabled && !this.state.paused) {
|
||||
this.setState({ paused: true, autoPaused: true });
|
||||
}
|
||||
}
|
||||
|
||||
if (AppState.currentState && AppState.currentState.match(/active/)) {
|
||||
if (!this.state.backgroundPlayEnabled && this.state.autoPaused) {
|
||||
this.setState({ paused: false, autoPaused: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onBuffer = () => {
|
||||
if (!this.state.paused) {
|
||||
this.setState({ buffering: true }, () => this.manualHidePlayerControls());
|
||||
}
|
||||
}
|
||||
|
||||
play = () => {
|
||||
this.setState({ paused: false }, this.updateBackgroundMediaNotification);
|
||||
}
|
||||
@@ -268,6 +336,7 @@ class MediaPlayer extends React.PureComponent {
|
||||
}
|
||||
|
||||
updateBackgroundMediaNotification = () => {
|
||||
this.handlePausedState();
|
||||
const { backgroundPlayEnabled } = this.props;
|
||||
if (backgroundPlayEnabled) {
|
||||
if (NativeModules.BackgroundMedia && window.currentMediaInfo) {
|
||||
@@ -278,13 +347,19 @@ class MediaPlayer extends React.PureComponent {
|
||||
}
|
||||
|
||||
renderPlayerControls() {
|
||||
const { onBackButtonPressed } = this.props;
|
||||
|
||||
if (this.state.areControlsVisible) {
|
||||
return (
|
||||
<View style={mediaPlayerStyle.playerControlsContainer}>
|
||||
<TouchableOpacity style={mediaPlayerStyle.backButton} onPress={onBackButtonPressed}>
|
||||
<Icon name={"arrow-left"} size={18} style={mediaPlayerStyle.backButtonIcon} />
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity style={mediaPlayerStyle.playPauseButton}
|
||||
onPress={this.togglePlay}>
|
||||
{this.state.paused && <Icon name="play" size={32} color="#ffffff" />}
|
||||
{!this.state.paused && <Icon name="pause" size={32} color="#ffffff" />}
|
||||
{this.state.paused && <Icon name="play" size={40} color="#ffffff" />}
|
||||
{!this.state.paused && <Icon name="pause" size={40} color="#ffffff" />}
|
||||
</TouchableOpacity>
|
||||
|
||||
<TouchableOpacity style={mediaPlayerStyle.toggleFullscreenButton} onPress={this.toggleFullscreenMode}>
|
||||
@@ -301,18 +376,6 @@ class MediaPlayer extends React.PureComponent {
|
||||
return null;
|
||||
}
|
||||
|
||||
getEncodedDownloadPath = (fileInfo) => {
|
||||
if (this.state.encodedFilePath) {
|
||||
return this.state.encodedFilePath;
|
||||
}
|
||||
|
||||
const { file_name: fileName } = fileInfo;
|
||||
const encodedFileName = encodeURIComponent(fileName).replace(/!/g, '%21');
|
||||
const encodedFilePath = fileInfo.download_path.replace(fileName, encodedFileName);
|
||||
this.setState({ encodedFilePath });
|
||||
return encodedFilePath;
|
||||
}
|
||||
|
||||
onSeekerTouchAreaPressed = (evt) => {
|
||||
if (evt && evt.nativeEvent) {
|
||||
const newSeekerPosition = evt.nativeEvent.locationX;
|
||||
@@ -324,8 +387,14 @@ class MediaPlayer extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
onTrackingLayout = (evt) => {
|
||||
this.trackingOffset = evt.nativeEvent.layout.x;
|
||||
this.seekerWidth = evt.nativeEvent.layout.width;
|
||||
this.setSeekerPosition(this.calculateSeekerPosition());
|
||||
}
|
||||
|
||||
render() {
|
||||
const { backgroundPlayEnabled, fileInfo, thumbnail, onLayout, style } = this.props;
|
||||
const { onLayout, source, style, thumbnail } = this.props;
|
||||
const completedWidth = this.getCurrentTimePercentage() * this.seekerWidth;
|
||||
const remainingWidth = this.seekerWidth - completedWidth;
|
||||
let styles = [this.state.fullscreenMode ? mediaPlayerStyle.fullscreenContainer : mediaPlayerStyle.container];
|
||||
@@ -342,34 +411,47 @@ class MediaPlayer extends React.PureComponent {
|
||||
|
||||
return (
|
||||
<View style={styles} onLayout={onLayout}>
|
||||
<Video source={{ uri: 'file:///' + this.getEncodedDownloadPath(fileInfo) }}
|
||||
<Video source={{ uri: source }}
|
||||
bufferConfig={{ minBufferMs: 15000, maxBufferMs: 60000, bufferForPlaybackMs: 5000, bufferForPlaybackAfterRebufferMs: 5000 }}
|
||||
ref={(ref: Video) => { this.video = ref; }}
|
||||
resizeMode={this.state.resizeMode}
|
||||
playInBackground={backgroundPlayEnabled}
|
||||
playInBackground={this.state.backgroundPlayEnabled}
|
||||
style={mediaPlayerStyle.player}
|
||||
rate={this.state.rate}
|
||||
volume={this.state.volume}
|
||||
paused={this.state.paused}
|
||||
onLoad={this.onLoad}
|
||||
onBuffer={this.onBuffer}
|
||||
onProgress={this.onProgress}
|
||||
onEnd={this.onEnd}
|
||||
onError={this.onError}
|
||||
minLoadRetryCount={999}
|
||||
/>
|
||||
|
||||
{this.state.firstPlay && thumbnail && thumbnail.trim().length > 0 &&
|
||||
<FastImage
|
||||
source={{uri: thumbnail}}
|
||||
resizeMode={FastImage.resizeMode.cover}
|
||||
style={mediaPlayerStyle.playerThumbnail}
|
||||
/>}
|
||||
|
||||
<TouchableOpacity style={mediaPlayerStyle.playerControls} onPress={this.togglePlayerControls}>
|
||||
{this.renderPlayerControls()}
|
||||
</TouchableOpacity>
|
||||
|
||||
{(!this.state.fullscreenMode || (this.state.fullscreenMode && this.state.areControlsVisible)) &&
|
||||
<View style={trackingStyle} onLayout={(evt) => {
|
||||
this.trackingOffset = evt.nativeEvent.layout.x;
|
||||
this.seekerWidth = evt.nativeEvent.layout.width;
|
||||
}}>
|
||||
<View style={trackingStyle} onLayout={this.onTrackingLayout}>
|
||||
<View style={mediaPlayerStyle.progress}>
|
||||
<View style={[mediaPlayerStyle.innerProgressCompleted, { width: completedWidth }]} />
|
||||
<View style={[mediaPlayerStyle.innerProgressRemaining, { width: remainingWidth }]} />
|
||||
</View>
|
||||
</View>}
|
||||
|
||||
{this.state.buffering &&
|
||||
<View style={mediaPlayerStyle.loadingContainer}>
|
||||
<ActivityIndicator color={Colors.LbryGreen} size="large" />
|
||||
</View>}
|
||||
|
||||
{this.state.areControlsVisible &&
|
||||
<View style={{ left: this.getTrackingOffset(), width: this.seekerWidth }}>
|
||||
<View style={[mediaPlayerStyle.seekerHandle,
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
View
|
||||
} from 'react-native';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import NavigationButton from '../navigationButton';
|
||||
import pageHeaderStyle from '../../styles/pageHeader';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
import pageHeaderStyle from 'styles/pageHeader';
|
||||
|
||||
const APPBAR_HEIGHT = Platform.OS === 'ios' ? 44 : 56;
|
||||
const AnimatedText = Animated.Text;
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import {
|
||||
doUserPhoneNew,
|
||||
doUserPhoneVerify,
|
||||
selectPhoneNewErrorMessage,
|
||||
selectPhoneNewIsPending,
|
||||
selectPhoneToVerify,
|
||||
selectPhoneVerifyIsPending,
|
||||
selectPhoneVerifyErrorMessage
|
||||
} from 'lbryinc';
|
||||
import PhoneNumberRewardSubcard from './view';
|
||||
|
||||
const select = state => ({
|
||||
phoneVerifyErrorMessage: selectPhoneVerifyErrorMessage(state),
|
||||
phoneVerifyIsPending: selectPhoneVerifyIsPending(state),
|
||||
phone: selectPhoneToVerify(state),
|
||||
phoneNewErrorMessage: selectPhoneNewErrorMessage(state),
|
||||
phoneNewIsPending: selectPhoneNewIsPending(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserPhone: (phone, country_code) => dispatch(doUserPhoneNew(phone, country_code)),
|
||||
verifyPhone: (verificationCode) => dispatch(doUserPhoneVerify(verificationCode)),
|
||||
notify: data => dispatch(doNotify(data)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(PhoneNumberRewardSubcard);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import ProgressBar from './view';
|
||||
|
||||
export default connect()(ProgressBar);
|
||||
@@ -0,0 +1,54 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { View } from 'react-native';
|
||||
|
||||
const defaultHeight = 5;
|
||||
const defaultBorderRadius = 5;
|
||||
const minProgress = 0;
|
||||
const maxProgress = 100;
|
||||
|
||||
class ProgressBar extends React.PureComponent {
|
||||
static propTypes = {
|
||||
borderRadius: PropTypes.number,
|
||||
color: PropTypes.string.isRequired,
|
||||
height: PropTypes.number,
|
||||
progress: function(props, propName, componentName) {
|
||||
const value = parseInt(props[propName], 10);
|
||||
if (isNaN(value) || props[propName] < minProgress || props[propName] > maxProgress) {
|
||||
return new Error('progress should be between 0 and 100');
|
||||
}
|
||||
},
|
||||
style: PropTypes.any
|
||||
};
|
||||
|
||||
render() {
|
||||
const { borderRadius, color, height, progress, style } = this.props;
|
||||
const currentProgress = Math.ceil(progress);
|
||||
|
||||
let styles = [];
|
||||
if (style) {
|
||||
if (style.length) {
|
||||
styles = styles.concat(style);
|
||||
} else {
|
||||
styles.push(style);
|
||||
}
|
||||
}
|
||||
|
||||
styles.push({
|
||||
borderRadius: borderRadius || defaultBorderRadius,
|
||||
flexDirection: 'row',
|
||||
height: height || defaultHeight,
|
||||
overflow: 'hidden'
|
||||
});
|
||||
|
||||
return (
|
||||
<View style={styles}>
|
||||
<View style={{ backgroundColor: color, borderRadius: borderRadius || defaultBorderRadius, flex: currentProgress }} />
|
||||
<View style={{ backgroundColor: color, opacity: 0.2, flex: (100 - currentProgress) }} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default ProgressBar;
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
makeSelectClaimForUri,
|
||||
doSearch,
|
||||
makeSelectRecommendedContentForUri,
|
||||
makeSelectTitleForUri,
|
||||
selectIsSearching,
|
||||
} from 'lbry-redux';
|
||||
import RelatedContent from './view';
|
||||
@@ -10,11 +11,12 @@ import RelatedContent from './view';
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
recommendedContent: makeSelectRecommendedContentForUri(props.uri)(state),
|
||||
title: makeSelectTitleForUri(props.uri)(state),
|
||||
isSearching: selectIsSearching(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: query => dispatch(doSearch(query, 10, undefined, true)),
|
||||
search: query => dispatch(doSearch(query, 20, undefined, true)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
|
||||
import { navigateToUri } from '../../utils/helper';
|
||||
import Colors from '../../styles/colors';
|
||||
import FileListItem from '../fileListItem';
|
||||
import fileListStyle from '../../styles/fileList';
|
||||
import relatedContentStyle from '../../styles/relatedContent';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
import relatedContentStyle from 'styles/relatedContent';
|
||||
|
||||
export default class RelatedContent extends React.PureComponent<Props> {
|
||||
constructor() {
|
||||
@@ -30,10 +30,9 @@ export default class RelatedContent extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
getRecommendedContent() {
|
||||
const { claim, search } = this.props;
|
||||
const { search, title } = this.props;
|
||||
|
||||
if (claim && claim.value && claim.value.stream && claim.value.stream.metadata) {
|
||||
const { title } = claim.value.stream.metadata;
|
||||
if (title) {
|
||||
search(title);
|
||||
this.didSearch = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import {
|
||||
doClaimRewardType,
|
||||
doClaimRewardClearError,
|
||||
@@ -23,7 +23,7 @@ const makeSelect = () => {
|
||||
const perform = dispatch => ({
|
||||
claimReward: reward => dispatch(doClaimRewardType(reward.reward_type, true)),
|
||||
clearError: reward => dispatch(doClaimRewardClearError(reward)),
|
||||
notify: data => dispatch(doNotify(data))
|
||||
notify: data => dispatch(doToast(data))
|
||||
});
|
||||
|
||||
export default connect(makeSelect, perform)(RewardCard);
|
||||
@@ -30,10 +30,10 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
const { clearError, notify, reward } = this.props;
|
||||
if (this.state.claimStarted && !isPending) {
|
||||
if (errorMessage && errorMessage.trim().length > 0) {
|
||||
notify({ message: errorMessage, displayType: ['toast'] });
|
||||
notify({ message: errorMessage });
|
||||
clearError(reward);
|
||||
} else {
|
||||
notify({ message: 'Reward successfully claimed!', displayType: ['toast'] });
|
||||
notify({ message: 'Reward successfully claimed!' });
|
||||
}
|
||||
this.setState({ claimStarted: false });
|
||||
}
|
||||
@@ -44,11 +44,15 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
canClaim,
|
||||
claimReward,
|
||||
notify,
|
||||
reward
|
||||
reward,
|
||||
showVerification
|
||||
} = this.props;
|
||||
|
||||
if (!canClaim) {
|
||||
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.', displayType: ['toast'] });
|
||||
if (showVerification) {
|
||||
showVerification();
|
||||
}
|
||||
notify({ message: 'Unfortunately, you are not eligible to claim this reward at this time.' });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,16 +66,20 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
const claimed = !!reward.transaction_id;
|
||||
|
||||
return (
|
||||
<View style={[rewardStyle.rewardCard, rewardStyle.row]}>
|
||||
<TouchableOpacity style={[rewardStyle.rewardCard, rewardStyle.row]} onPress={() => {
|
||||
if (!isPending && !claimed) {
|
||||
this.onClaimPress();
|
||||
}
|
||||
}}>
|
||||
<View style={rewardStyle.leftCol}>
|
||||
{!isPending && <TouchableOpacity onPress={() => {
|
||||
if (!claimed) {
|
||||
this.onClaimPress();
|
||||
}
|
||||
}}>
|
||||
<Icon name={claimed ? "check-circle" : "circle"}
|
||||
{claimed && <Icon name={claimed ? "check-circle" : "circle"}
|
||||
style={claimed ? rewardStyle.claimed : (canClaim ? rewardStyle.unclaimed : rewardStyle.disabled)}
|
||||
size={20} />
|
||||
size={20} />}
|
||||
</TouchableOpacity>}
|
||||
{isPending && <ActivityIndicator size="small" color={Colors.LbryGreen} />}
|
||||
</View>
|
||||
@@ -79,7 +87,7 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
<Text style={rewardStyle.rewardTitle}>{reward.reward_title}</Text>
|
||||
<Text style={rewardStyle.rewardDescription}>{reward.reward_description}</Text>
|
||||
{claimed && <Link style={rewardStyle.link}
|
||||
href={`https://explorer.lbry.io/tx/${reward.transaction_id}`}
|
||||
href={`https://explorer.lbry.com/tx/${reward.transaction_id}`}
|
||||
text={reward.transaction_id.substring(0, 7)}
|
||||
error={'The transaction URL could not be opened'} />}
|
||||
</View>
|
||||
@@ -87,7 +95,7 @@ class RewardCard extends React.PureComponent<Props> {
|
||||
<Text style={rewardStyle.rewardAmount}>{reward.reward_amount}</Text>
|
||||
<Text style={rewardStyle.rewardCurrency}>LBC</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc';
|
||||
import RewardEnrolment from './view';
|
||||
|
||||
const select = state => ({
|
||||
unclaimedRewardAmount: selectUnclaimedRewardValue(state),
|
||||
fetching: selectFetchingRewards(state),
|
||||
user: selectUser(state)
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchRewards: () => dispatch(doRewardList()),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(RewardEnrolment);
|
||||
@@ -0,0 +1,53 @@
|
||||
import React from 'react';
|
||||
import { NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
import Constants from 'constants';
|
||||
import Link from 'component/link';
|
||||
import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import rewardStyle from 'styles/reward';
|
||||
|
||||
class RewardEnrolment extends React.Component {
|
||||
componentDidMount() {
|
||||
this.props.fetchRewards();
|
||||
}
|
||||
|
||||
onNotInterestedPressed = () => {
|
||||
const { navigation, setClientSetting } = this.props;
|
||||
setClientSetting(Constants.SETTING_REWARDS_NOT_INTERESTED, true);
|
||||
navigation.navigate({ routeName: 'DiscoverStack' });
|
||||
}
|
||||
|
||||
onEnrollPressed = () => {
|
||||
const { navigation } = this.props;
|
||||
navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: false }});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { fetching, navigation, unclaimedRewardAmount, user } = this.props;
|
||||
|
||||
return (
|
||||
<View style={rewardStyle.enrollContainer} onPress>
|
||||
<View style={rewardStyle.summaryRow}>
|
||||
<Icon name="award" size={36} color={Colors.White} />
|
||||
<Text style={rewardStyle.summaryText}>
|
||||
{unclaimedRewardAmount} unclaimed credits
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View style={rewardStyle.onboarding}>
|
||||
<Text style={rewardStyle.enrollDescText}>LBRY credits allow you to purchase content, publish content, and influence the network. You can start earning credits by watching videos on LBRY.</Text>
|
||||
</View>
|
||||
|
||||
<View style={rewardStyle.buttonRow}>
|
||||
<Link style={rewardStyle.notInterestedLink} text={"Not interested"} onPress={this.onNotInterestedPressed} />
|
||||
<Button style={rewardStyle.enrollButton} theme={"light"} text={"Enroll"} onPress={this.onEnrollPressed} />
|
||||
</View>
|
||||
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default RewardEnrolment;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import { doRewardList, selectUnclaimedRewardValue, selectFetchingRewards, selectUser } from 'lbryinc';
|
||||
import RewardSummary from './view';
|
||||
|
||||
@@ -11,7 +11,7 @@ const select = state => ({
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchRewards: () => dispatch(doRewardList()),
|
||||
notify: data => dispatch(doNotify(data))
|
||||
notify: data => dispatch(doToast(data))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(RewardSummary);
|
||||
@@ -1,7 +1,10 @@
|
||||
import React from 'react';
|
||||
import { AsyncStorage, NativeModules, Text, TouchableOpacity } from 'react-native';
|
||||
import Button from '../../component/button';
|
||||
import rewardStyle from '../../styles/reward';
|
||||
import { NativeModules, Text, TouchableOpacity, View } from 'react-native';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import rewardStyle from 'styles/reward';
|
||||
|
||||
class RewardSummary extends React.Component {
|
||||
static itemKey = 'rewardSummaryDismissed';
|
||||
@@ -38,13 +41,23 @@ class RewardSummary extends React.Component {
|
||||
this.setState({ dismissed: true });
|
||||
this.props.notify({
|
||||
message: 'You can always claim your rewards from the Rewards page.',
|
||||
displayType: ['toast']
|
||||
});
|
||||
}
|
||||
|
||||
handleSummaryPressed = () => {
|
||||
const { showVerification } = this.props;
|
||||
if (showVerification) {
|
||||
showVerification();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { fetching, navigation, unclaimedRewardAmount, user } = this.props;
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.state.dismissed ||
|
||||
(user && user.is_reward_approved) ||
|
||||
this.state.actionsLeft === 0 ||
|
||||
@@ -53,12 +66,13 @@ class RewardSummary extends React.Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={rewardStyle.summaryContainer} onPress={() => {
|
||||
navigation.navigate('Rewards');
|
||||
}}>
|
||||
<Text style={rewardStyle.summaryText}>
|
||||
You have {unclaimedRewardAmount} LBC in unclaimed rewards. You have {this.state.actionsLeft} action{this.state.actionsLeft === 1 ? '' : 's'} left to claim your first reward. Tap here to continue.
|
||||
</Text>
|
||||
<TouchableOpacity style={rewardStyle.summaryContainer} onPress={this.handleSummaryPressed}>
|
||||
<View style={rewardStyle.summaryRow}>
|
||||
<Icon name="award" size={36} color={Colors.White} />
|
||||
<Text style={rewardStyle.summaryText}>
|
||||
{unclaimedRewardAmount} unclaimed credits
|
||||
</Text>
|
||||
</View>
|
||||
<Button style={rewardStyle.dismissButton} theme={"light"} text={"Dismiss"} onPress={this.onDismissPressed} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
||||
@@ -5,8 +5,8 @@ import SearchInput from './view';
|
||||
|
||||
const perform = dispatch => ({
|
||||
search: search => {
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Search', { Query: search });
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('search', { query: search });
|
||||
}
|
||||
return dispatch(doSearch(search));
|
||||
},
|
||||
|
||||
@@ -66,6 +66,10 @@ class StorageStatsCard extends React.PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.totalBytes == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={storageStatsStyle.card}>
|
||||
<View style={[storageStatsStyle.row, storageStatsStyle.totalSizeContainer]}>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doChannelSubscribe,
|
||||
doChannelUnsubscribe,
|
||||
selectSubscriptions,
|
||||
makeSelectIsSubscribed,
|
||||
} from 'lbryinc';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import SubscribeButton from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
subscriptions: selectSubscriptions(state),
|
||||
isSubscribed: makeSelectIsSubscribed(props.uri, true)(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
{
|
||||
doChannelSubscribe,
|
||||
doChannelUnsubscribe,
|
||||
doToast,
|
||||
}
|
||||
)(SubscribeButton);
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import { normalizeURI, parseURI } from 'lbry-redux';
|
||||
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
|
||||
import Button from '../button';
|
||||
import Colors from '../../styles/colors';
|
||||
|
||||
class SubscribeButton extends React.PureComponent {
|
||||
render() {
|
||||
const {
|
||||
uri,
|
||||
isSubscribed,
|
||||
doChannelSubscribe,
|
||||
doChannelUnsubscribe,
|
||||
style
|
||||
} = this.props;
|
||||
|
||||
let styles = [];
|
||||
if (style) {
|
||||
if (style.length) {
|
||||
styles = styles.concat(style);
|
||||
} else {
|
||||
styles.push(style);
|
||||
}
|
||||
}
|
||||
|
||||
const iconColor = isSubscribed ? null : Colors.Red;
|
||||
const subscriptionHandler = isSubscribed ? doChannelUnsubscribe : doChannelSubscribe;
|
||||
const subscriptionLabel = isSubscribed ? null : __('Subscribe');
|
||||
const { claimName } = parseURI(uri);
|
||||
|
||||
return (
|
||||
<Button
|
||||
style={styles}
|
||||
theme={"light"}
|
||||
icon={isSubscribed ? "heart-broken" : "heart"}
|
||||
iconColor={iconColor}
|
||||
solid={isSubscribed ? false : true}
|
||||
text={subscriptionLabel}
|
||||
onPress={() => {
|
||||
subscriptionHandler({
|
||||
channelName: claimName,
|
||||
uri: normalizeURI(uri),
|
||||
});
|
||||
}} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SubscribeButton;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doChannelSubscriptionEnableNotifications,
|
||||
doChannelSubscriptionDisableNotifications,
|
||||
selectEnabledChannelNotifications,
|
||||
selectSubscriptions,
|
||||
makeSelectIsSubscribed,
|
||||
} from 'lbryinc';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import SubscribeNotificationButton from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
enabledChannelNotifications: selectEnabledChannelNotifications(state),
|
||||
subscriptions: selectSubscriptions(state),
|
||||
isSubscribed: makeSelectIsSubscribed(props.uri, true)(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
{
|
||||
doChannelSubscriptionEnableNotifications,
|
||||
doChannelSubscriptionDisableNotifications,
|
||||
doToast,
|
||||
}
|
||||
)(SubscribeNotificationButton);
|
||||
@@ -0,0 +1,55 @@
|
||||
import React from 'react';
|
||||
import { parseURI } from 'lbry-redux';
|
||||
import { NativeModules, Text, View, TouchableOpacity } from 'react-native';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
|
||||
class SubscribeNotificationButton extends React.PureComponent {
|
||||
render() {
|
||||
const {
|
||||
uri,
|
||||
name,
|
||||
doChannelSubscriptionEnableNotifications,
|
||||
doChannelSubscriptionDisableNotifications,
|
||||
doToast,
|
||||
enabledChannelNotifications,
|
||||
isSubscribed,
|
||||
style
|
||||
} = this.props;
|
||||
|
||||
if (!isSubscribed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let styles = [];
|
||||
if (style) {
|
||||
if (style.length) {
|
||||
styles = styles.concat(style);
|
||||
} else {
|
||||
styles.push(style);
|
||||
}
|
||||
}
|
||||
|
||||
const shouldNotify = enabledChannelNotifications.indexOf(name) > -1;
|
||||
const { claimName } = parseURI(uri);
|
||||
|
||||
return (
|
||||
<Button
|
||||
style={styles}
|
||||
theme={"light"}
|
||||
icon={shouldNotify ? "bell-slash" : "bell"}
|
||||
solid={true}
|
||||
onPress={() => {
|
||||
if (shouldNotify) {
|
||||
doChannelSubscriptionDisableNotifications(name);
|
||||
doToast({ message: 'You will not receive notifications for new content.' });
|
||||
} else {
|
||||
doChannelSubscriptionEnableNotifications(name);
|
||||
doToast({ message: 'You will receive all notifications for new content.' });
|
||||
}
|
||||
}} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SubscribeNotificationButton;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectClaimsInChannelForPage,
|
||||
doFetchClaimsByChannel,
|
||||
doResolveUris,
|
||||
} from 'lbry-redux';
|
||||
import { selectShowNsfw } from 'redux/selectors/settings';
|
||||
import SuggestedSubscriptionItem from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claims: makeSelectClaimsInChannelForPage(props.categoryLink)(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
|
||||
obscureNsfw: !selectShowNsfw(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
|
||||
resolveUris: uris => dispatch(doResolveUris(uris, true)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
perform
|
||||
)(SuggestedSubscriptionItem);
|
||||
@@ -0,0 +1,74 @@
|
||||
import React from 'react';
|
||||
import { buildURI, normalizeURI } from 'lbry-redux';
|
||||
import { ActivityIndicator, FlatList, Text, View } from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FileItem from 'component/fileItem';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
|
||||
class SuggestedSubscriptionItem extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { fetching, categoryLink, fetchChannel, resolveUris, claims } = this.props;
|
||||
if (!fetching && categoryLink && (!claims || claims.length)) {
|
||||
fetchChannel(categoryLink);
|
||||
}
|
||||
}
|
||||
|
||||
uriForClaim = (claim) => {
|
||||
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = claim;
|
||||
const uriParams = {};
|
||||
|
||||
// This is unfortunate
|
||||
// https://github.com/lbryio/lbry/issues/1159
|
||||
const name = claimName || claimNameDownloaded;
|
||||
uriParams.contentName = name;
|
||||
uriParams.claimId = claimId;
|
||||
const uri = buildURI(uriParams);
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
render() {
|
||||
const { categoryLink, fetching, obscureNsfw, claims, navigation } = this.props;
|
||||
|
||||
if (!claims || !claims.length) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.busyContainer}>
|
||||
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
if (claims && claims.length > 0) {
|
||||
return (
|
||||
<View style={subscriptionsStyle.suggestedContainer}>
|
||||
<FileItem
|
||||
style={subscriptionsStyle.compactMainFileItem}
|
||||
mediaStyle={subscriptionsStyle.fileItemMedia}
|
||||
uri={this.uriForClaim(claims[0])}
|
||||
navigation={navigation} />
|
||||
{(claims.length > 1) &&
|
||||
<FlatList style={subscriptionsStyle.compactItems}
|
||||
horizontal={true}
|
||||
renderItem={ ({item}) => (
|
||||
<FileItem
|
||||
style={subscriptionsStyle.compactFileItem}
|
||||
mediaStyle={subscriptionsStyle.compactFileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation}
|
||||
compactView={true} />
|
||||
)
|
||||
}
|
||||
data={claims.slice(1, 4).map(claim => this.uriForClaim(claim))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export default SuggestedSubscriptionItem;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { selectSuggestedChannels, selectIsFetchingSuggested } from 'lbryinc';
|
||||
import SuggestedSubscriptions from './view';
|
||||
|
||||
const select = state => ({
|
||||
suggested: selectSuggestedChannels(state),
|
||||
loading: selectIsFetchingSuggested(state),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
select,
|
||||
null
|
||||
)(SuggestedSubscriptions);
|
||||
@@ -0,0 +1,55 @@
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, SectionList, Text, View } from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SuggestedSubscriptionItem from 'component/suggestedSubscriptionItem';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import subscriptionsStyle from 'styles/subscriptions';
|
||||
import Link from 'component/link';
|
||||
|
||||
class SuggestedSubscriptions extends React.PureComponent {
|
||||
render() {
|
||||
const { suggested, loading, navigation } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<View>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return suggested ? (
|
||||
<SectionList style={subscriptionsStyle.scrollContainer}
|
||||
renderItem={ ({item, index, section}) => (
|
||||
<SuggestedSubscriptionItem
|
||||
key={item}
|
||||
categoryLink={normalizeURI(item)}
|
||||
navigation={navigation} />
|
||||
)
|
||||
}
|
||||
renderSectionHeader={
|
||||
({section: {title}}) => {
|
||||
const titleParts = title.split(';');
|
||||
const channelName = titleParts[0];
|
||||
const channelUri = normalizeURI(titleParts[1]);
|
||||
return (
|
||||
<View style={subscriptionsStyle.titleRow}>
|
||||
<Link style={subscriptionsStyle.channelTitle} text={channelName} onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(channelUri));
|
||||
}} />
|
||||
<SubscribeButton style={subscriptionsStyle.subscribeButton} uri={channelUri} name={channelName} />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
sections={suggested.map(({ uri, label }) => ({ title: (label + ';' + uri), data: [uri] }))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
) : null;
|
||||
}
|
||||
}
|
||||
|
||||
export default SuggestedSubscriptions;
|
||||
@@ -37,7 +37,7 @@ class TransactionListItem extends React.PureComponent {
|
||||
<View style={transactionListStyle.col}>
|
||||
<Link style={transactionListStyle.smallLink}
|
||||
text={txid.substring(0, 8)}
|
||||
href={`https://explorer.lbry.io/tx/${txid}`}
|
||||
href={`https://explorer.lbry.com/tx/${txid}`}
|
||||
error={'The transaction URL could not be opened'} />
|
||||
</View>
|
||||
<View style={transactionListStyle.col}>
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doUpdateSearchQuery, selectSearchState as selectSearch, selectSearchSuggestions } from 'lbry-redux';
|
||||
import {
|
||||
doUpdateSearchQuery,
|
||||
selectSearchState as selectSearch,
|
||||
selectSearchValue,
|
||||
selectSearchSuggestions
|
||||
} from 'lbry-redux';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import UriBar from './view';
|
||||
|
||||
const select = state => {
|
||||
const { ...searchState } = selectSearch(state);
|
||||
|
||||
|
||||
return {
|
||||
...searchState,
|
||||
query: selectSearchValue(state),
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
suggestions: selectSearchSuggestions(state)
|
||||
};
|
||||
};
|
||||
|
||||
@@ -29,7 +29,14 @@ class UriBarItem extends React.PureComponent {
|
||||
return (
|
||||
<TouchableOpacity style={uriBarStyle.item} onPress={onPress}>
|
||||
{icon}
|
||||
<Text style={uriBarStyle.itemText} numberOfLines={1}>{shorthand || value} - {type === 'search' ? 'Search' : value}</Text>
|
||||
<View style={uriBarStyle.itemContent}>
|
||||
<Text style={uriBarStyle.itemText} numberOfLines={1}>{shorthand || value} - {type === SEARCH_TYPES.SEARCH ? 'Search' : value}</Text>
|
||||
<Text style={uriBarStyle.itemDesc} numberOfLines={1}>
|
||||
{type === SEARCH_TYPES.SEARCH && `Search for '${value}'`}
|
||||
{type === SEARCH_TYPES.CHANNEL && `View the @${shorthand} channel`}
|
||||
{type === SEARCH_TYPES.FILE && `View content at ${value}`}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
import React from 'react';
|
||||
import { SEARCH_TYPES, isNameValid, isURIValid, normalizeURI } from 'lbry-redux';
|
||||
import { FlatList, Keyboard, TextInput, View } from 'react-native';
|
||||
import { navigateToUri } from '../../utils/helper';
|
||||
import { navigateToUri } from 'utils/helper';
|
||||
import Constants from 'constants';
|
||||
import UriBarItem from './internal/uri-bar-item';
|
||||
import uriBarStyle from '../../styles/uriBar';
|
||||
import NavigationButton from 'component/navigationButton';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import uriBarStyle from 'styles/uriBar';
|
||||
|
||||
class UriBar extends React.PureComponent {
|
||||
static INPUT_TIMEOUT = 500;
|
||||
static INPUT_TIMEOUT = 2500; // 2.5 seconds
|
||||
|
||||
textInput = null;
|
||||
|
||||
@@ -24,23 +27,49 @@ class UriBar extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute, query } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
|
||||
if (Constants.DRAWER_ROUTE_SEARCH === currentRoute && currentRoute !== prevRoute) {
|
||||
this.setState({ currentValue: query, inputText: query });
|
||||
}
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
changeTextTimeout: null,
|
||||
currentValue: null,
|
||||
inputText: null,
|
||||
focused: false
|
||||
focused: false,
|
||||
// TODO: Add a setting to enable / disable direct search?
|
||||
directSearch: true
|
||||
};
|
||||
}
|
||||
|
||||
handleChangeText = text => {
|
||||
const newValue = text ? text : '';
|
||||
clearTimeout(this.state.changeTextTimeout);
|
||||
const { updateSearchQuery } = this.props;
|
||||
const { updateSearchQuery, onSearchSubmitted, navigation } = this.props;
|
||||
|
||||
let timeout = setTimeout(() => {
|
||||
if (text.trim().length === 0) {
|
||||
// don't do anything if the text is empty
|
||||
return;
|
||||
}
|
||||
|
||||
updateSearchQuery(text);
|
||||
|
||||
if (!text.startsWith('lbry://')) {
|
||||
// not a URI input, so this is a search, perform a direct search
|
||||
if (onSearchSubmitted) {
|
||||
onSearchSubmitted(text);
|
||||
} else {
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: text }});
|
||||
}
|
||||
}
|
||||
|
||||
}, UriBar.INPUT_TIMEOUT);
|
||||
this.setState({ inputText: newValue, currentValue: newValue, changeTextTimeout: timeout });
|
||||
}
|
||||
@@ -80,35 +109,58 @@ class UriBar extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handleSubmitEditing = () => {
|
||||
const { navigation, onSearchSubmitted, updateSearchQuery } = this.props;
|
||||
if (this.state.inputText) {
|
||||
let inputText = this.state.inputText;
|
||||
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
|
||||
// if it's a URI (lbry://...), open the file page
|
||||
const uri = normalizeURI(inputText);
|
||||
navigateToUri(navigation, uri);
|
||||
} else {
|
||||
updateSearchQuery(inputText);
|
||||
// Not a URI, default to a search request
|
||||
if (onSearchSubmitted) {
|
||||
// Only the search page sets the onSearchSubmitted prop, so call this prop if set
|
||||
onSearchSubmitted(inputText);
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the search page with the query populated
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSearchPageBlurred() {
|
||||
this.setState({ currenValueSet: false });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigation, onSearchSubmitted, suggestions, updateSearchQuery, value } = this.props;
|
||||
const { navigation, suggestions, query, value } = this.props;
|
||||
if (this.state.currentValue === null) {
|
||||
this.setState({ currentValue: value });
|
||||
}
|
||||
|
||||
let style = [uriBarStyle.overlay];
|
||||
if (this.state.focused) {
|
||||
style.push(uriBarStyle.inFocus);
|
||||
}
|
||||
|
||||
// TODO: Add optional setting to enable URI / search bar suggestions
|
||||
/*if (this.state.focused) { style.push(uriBarStyle.inFocus); }*/
|
||||
|
||||
return (
|
||||
<View style={style}>
|
||||
{this.state.focused && (
|
||||
<View style={uriBarStyle.suggestions}>
|
||||
<FlatList style={uriBarStyle.suggestionList}
|
||||
data={suggestions}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
keyExtractor={(item, value) => item.value}
|
||||
renderItem={({item}) => <UriBarItem item={item}
|
||||
navigation={navigation}
|
||||
onPress={() => this.handleItemPress(item)} />} />
|
||||
</View>)}
|
||||
<View style={uriBarStyle.uriContainer}>
|
||||
<NavigationButton
|
||||
name="bars"
|
||||
size={24}
|
||||
style={uriBarStyle.drawerMenuButton}
|
||||
iconStyle={discoverStyle.drawerHamburger}
|
||||
onPress={() => navigation.openDrawer() } />
|
||||
<TextInput ref={(ref) => { this.textInput = ref }}
|
||||
style={uriBarStyle.uriText}
|
||||
onLayout={() => { this.setSelection(); }}
|
||||
selectTextOnFocus={true}
|
||||
placeholder={'Search for videos, music, games and more'}
|
||||
placeholder={'Search movies, music, and more'}
|
||||
underlineColorAndroid={'transparent'}
|
||||
numberOfLines={1}
|
||||
clearButtonMode={'while-editing'}
|
||||
@@ -122,26 +174,20 @@ class UriBar extends React.PureComponent {
|
||||
this.setSelection();
|
||||
}}
|
||||
onChangeText={this.handleChangeText}
|
||||
onSubmitEditing={() => {
|
||||
if (this.state.inputText) {
|
||||
let inputText = this.state.inputText;
|
||||
if (inputText.startsWith('lbry://') && isURIValid(inputText)) {
|
||||
// if it's a URI (lbry://...), open the file page
|
||||
const uri = normalizeURI(inputText);
|
||||
navigateToUri(navigation, uri);
|
||||
} else {
|
||||
// Not a URI, default to a search request
|
||||
if (onSearchSubmitted) {
|
||||
// Only the search page sets the onSearchSubmitted prop, so call this prop if set
|
||||
onSearchSubmitted(inputText);
|
||||
return;
|
||||
}
|
||||
|
||||
// Open the search page with the query populated
|
||||
navigation.navigate({ routeName: 'Search', key: 'searchPage', params: { searchQuery: inputText }});
|
||||
}
|
||||
}
|
||||
}}/>
|
||||
onSubmitEditing={this.handleSubmitEditing}/>
|
||||
{(this.state.focused && !this.state.directSearch) && (
|
||||
<View style={uriBarStyle.suggestions}>
|
||||
<FlatList style={uriBarStyle.suggestionList}
|
||||
data={suggestions}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
keyExtractor={(item, value) => item.value}
|
||||
renderItem={({item}) => (
|
||||
<UriBarItem
|
||||
item={item}
|
||||
navigation={navigation}
|
||||
onPress={() => this.handleItemPress(item)}
|
||||
/>)} />
|
||||
</View>)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ class WalletAddress extends React.PureComponent<Props> {
|
||||
<Address address={receiveAddress} style={walletStyle.bottomMarginSmall} />
|
||||
<Button style={[walletStyle.button, walletStyle.bottomMarginLarge]}
|
||||
icon={'sync'}
|
||||
text={'Get New Address'}
|
||||
text={'Get new address'}
|
||||
onPress={getNewAddress}
|
||||
disabled={gettingNewAddress}
|
||||
/>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { Image, Text, View } from 'react-native';
|
||||
import { formatCredits } from 'lbry-redux'
|
||||
import Address from '../address';
|
||||
import Button from '../button';
|
||||
import walletStyle from '../../styles/wallet';
|
||||
import { Lbry, formatCredits } from 'lbry-redux'
|
||||
import Address from 'component/address';
|
||||
import Button from 'component/button';
|
||||
import walletStyle from 'styles/wallet';
|
||||
|
||||
type Props = {
|
||||
balance: number,
|
||||
@@ -19,7 +19,7 @@ class WalletBalance extends React.PureComponent<Props> {
|
||||
<Text style={walletStyle.balanceTitle}>Balance</Text>
|
||||
<Text style={walletStyle.balanceCaption}>You currently have</Text>
|
||||
<Text style={walletStyle.balance}>
|
||||
{(balance || balance === 0) && (formatCredits(balance, 2) + ' LBC')}
|
||||
{(balance || balance === 0) && (formatCredits(parseFloat(balance), 2) + ' LBC')}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { connect } from 'react-redux';
|
||||
import WalletRewardsDriver from './view';
|
||||
|
||||
export default connect()(WalletRewardsDriver);
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Text, TouchableOpacity } from 'react-native';
|
||||
import walletStyle from 'styles/wallet';
|
||||
|
||||
class WalletRewardsDriver extends React.PureComponent<Props> {
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
|
||||
return (
|
||||
<TouchableOpacity style={walletStyle.rewardDriverCard} onPress={() => navigation.navigate('Rewards')}>
|
||||
<Text style={walletStyle.rewardDriverText}>Earn credits while using the LBRY app. Tap to get started.</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default WalletRewardsDriver;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doNotify,
|
||||
doToast,
|
||||
doSendDraftTransaction,
|
||||
selectDraftTransaction,
|
||||
selectDraftTransactionError,
|
||||
@@ -8,15 +8,15 @@ import {
|
||||
} from 'lbry-redux';
|
||||
import WalletSend from './view';
|
||||
|
||||
const perform = dispatch => ({
|
||||
sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)),
|
||||
notify: (data) => dispatch(doNotify(data))
|
||||
});
|
||||
|
||||
const select = state => ({
|
||||
balance: selectBalance(state),
|
||||
draftTransaction: selectDraftTransaction(state),
|
||||
transactionError: selectDraftTransactionError(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
sendToAddress: (address, amount) => dispatch(doSendDraftTransaction(address, amount)),
|
||||
notify: (data) => dispatch(doToast(data))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(WalletSend);
|
||||
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { regexAddress } from 'lbry-redux';
|
||||
import { TextInput, Text, View } from 'react-native';
|
||||
import { Alert, TextInput, Text, View } from 'react-native';
|
||||
import Button from '../button';
|
||||
import walletStyle from '../../styles/wallet';
|
||||
|
||||
@@ -38,7 +38,6 @@ class WalletSend extends React.PureComponent<Props> {
|
||||
if (address && !regexAddress.test(address)) {
|
||||
notify({
|
||||
message: 'The recipient address is not a valid LBRY address.',
|
||||
displayType: ['toast']
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -46,14 +45,22 @@ class WalletSend extends React.PureComponent<Props> {
|
||||
if (amount > balance) {
|
||||
notify({
|
||||
message: 'Insufficient credits',
|
||||
displayType: ['toast']
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount && address) {
|
||||
sendToAddress(address, parseFloat(amount));
|
||||
this.setState({ address: null, amount: null });
|
||||
// Show confirmation before send
|
||||
Alert.alert(
|
||||
'Send LBC',
|
||||
`Are you sure you want to send ${amount} LBC to ${address}?`,
|
||||
[
|
||||
{ text: 'No' },
|
||||
{ text: 'Yes', onPress: () => {
|
||||
sendToAddress(address, parseFloat(amount));
|
||||
this.setState({ address: null, amount: null });
|
||||
}}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +69,6 @@ class WalletSend extends React.PureComponent<Props> {
|
||||
const { notify } = this.props;
|
||||
notify({
|
||||
message: 'The recipient address is not a valid LBRY address.',
|
||||
displayType: ['toast']
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -102,6 +108,7 @@ class WalletSend extends React.PureComponent<Props> {
|
||||
<TextInput ref={ref => this.amountInput = ref}
|
||||
onChangeText={value => this.setState({amount: value})}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.amount}
|
||||
style={[walletStyle.input, walletStyle.amountInput]} />
|
||||
<Text style={[walletStyle.text, walletStyle.currency]}>LBC</Text>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import WalletSyncDriver from './view';
|
||||
|
||||
const select = state => ({
|
||||
deviceWalletSynced: makeSelectClientSetting(Constants.SETTING_DEVICE_WALLET_SYNCED)(state),
|
||||
});
|
||||
|
||||
export default connect(select, null)(WalletSyncDriver);
|
||||
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import { Text, View } from 'react-native';
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import walletStyle from 'styles/wallet';
|
||||
|
||||
class WalletSyncDriver extends React.PureComponent<Props> {
|
||||
onEnableSyncPressed = () => {
|
||||
const { navigation } = this.props;
|
||||
navigation.navigate({ routeName: 'Verification', key: 'verification', params: { syncFlow: true } });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { deviceWalletSynced } = this.props;
|
||||
|
||||
return (
|
||||
<View style={walletStyle.syncDriverCard}>
|
||||
<View style={walletStyle.syncDriverRow}>
|
||||
<Text style={walletStyle.syncDriverTitle}>Wallet sync is {deviceWalletSynced ? 'on' : 'off'}.</Text>
|
||||
{!deviceWalletSynced &&
|
||||
<Link text="Sync FAQ" href="https://lbry.com/faq/how-to-backup-wallet#sync" style={walletStyle.syncDriverText} />}
|
||||
</View>
|
||||
{!deviceWalletSynced &&
|
||||
<View style={walletStyle.actionRow}>
|
||||
<Button style={walletStyle.enrollButton} theme={"light"} text={"Enable"} onPress={this.onEnableSyncPressed} />
|
||||
<Link text="Manual backup" href="https://lbry.com/faq/how-to-backup-wallet#android" style={walletStyle.syncDriverText} />
|
||||
</View>}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default WalletSyncDriver;
|
||||
@@ -1,11 +1,86 @@
|
||||
const Constants = {
|
||||
FIRST_RUN_PAGE_WELCOME: "welcome",
|
||||
FIRST_RUN_PAGE_EMAIL_COLLECT: "email-collect",
|
||||
FIRST_RUN_PAGE_EMAIL_VERIFY:"email-verify",
|
||||
FIRST_RUN_PAGE_WALLET: "wallet",
|
||||
FIRST_RUN_PAGE_SKIP_ACCOUNT: "skip-account",
|
||||
|
||||
VERIFY_PAGE_EMAIL: "email-verify",
|
||||
VERIFY_PAGE_PHONE_NUMBER: "phone-number-verify",
|
||||
|
||||
PHASE_COLLECTION: "collection",
|
||||
PHASE_VERIFICATION: "verification",
|
||||
|
||||
CONTENT_TAB: "content",
|
||||
ABOUT_TAB: "about",
|
||||
|
||||
KEY_FIRST_RUN_EMAIL: "firstRunEmail",
|
||||
KEY_FIRST_RUN_PASSWORD: "firstRunPassword",
|
||||
KEY_FIRST_USER_AUTH: "firstUserAuth",
|
||||
KEY_SHOULD_VERIFY_EMAIL: "shouldVerifyEmail",
|
||||
KEY_EMAIL_VERIFY_PENDING: "emailVerifyPending",
|
||||
|
||||
SETTING_ALPHA_UNDERSTANDS_RISKS: "alphaUnderstandRisks",
|
||||
SETTING_SUBSCRIPTIONS_VIEW_MODE: "subscriptionsViewMode",
|
||||
SETTING_RATING_REMINDER_LAST_SHOWN: "ratingReminderLastShown",
|
||||
SETTING_RATING_REMINDER_DISABLED: "ratingReminderDisabled",
|
||||
SETTING_BACKUP_DISMISSED: "backupDismissed",
|
||||
SETTING_REWARDS_NOT_INTERESTED: "rewardsNotInterested",
|
||||
SETTING_DEVICE_WALLET_SYNCED: "deviceWalletSynced",
|
||||
|
||||
ACTION_DELETE_COMPLETED_BLOBS: "DELETE_COMPLETED_BLOBS",
|
||||
ACTION_FIRST_RUN_PAGE_CHANGED: "FIRST_RUN_PAGE_CHANGED",
|
||||
|
||||
ACTION_PUSH_DRAWER_STACK: "PUSH_DRAWER_STACK",
|
||||
ACTION_POP_DRAWER_STACK: "POP_DRAWER_STACK",
|
||||
ACTION_SET_PLAYER_VISIBLE: "SET_PLAYER_VISIBLE",
|
||||
|
||||
ACTION_REACT_NAVIGATION_RESET: "Navigation/RESET",
|
||||
ACTION_REACT_NAVIGATION_NAVIGATE: "Navigation/NAVIGATE",
|
||||
ACTION_REACT_NAVIGATION_REPLACE: "Navigation/REPLACE",
|
||||
|
||||
PAGE_REWARDS: "rewards",
|
||||
PAGE_SETTINGS: "settings",
|
||||
PAGE_TRENDING: "trending",
|
||||
PAGE_WALLET: "wallet",
|
||||
|
||||
DRAWER_ROUTE_DISCOVER: "Discover",
|
||||
DRAWER_ROUTE_TRENDING: "Trending",
|
||||
DRAWER_ROUTE_SUBSCRIPTIONS: "Subscriptions",
|
||||
DRAWER_ROUTE_MY_LBRY: "Downloads",
|
||||
DRAWER_ROUTE_REWARDS: "Rewards",
|
||||
DRAWER_ROUTE_WALLET: "Wallet",
|
||||
DRAWER_ROUTE_SETTINGS: "Settings",
|
||||
DRAWER_ROUTE_ABOUT: "About",
|
||||
DRAWER_ROUTE_SEARCH: "Search",
|
||||
DRAWER_ROUTE_TRANSACTION_HISTORY: "TransactionHistory",
|
||||
|
||||
FULL_ROUTE_NAME_DISCOVER: "DiscoverStack",
|
||||
FULL_ROUTE_NAME_TRENDING: "TrendingStack",
|
||||
FULL_ROUTE_NAME_MY_SUBSCRIPTIONS: "MySubscriptionsStack",
|
||||
FULL_ROUTE_NAME_WALLET: "WalletStack",
|
||||
FULL_ROUTE_NAME_MY_LBRY: "MyLBRYStack",
|
||||
|
||||
ROUTE_FILE: "File",
|
||||
|
||||
SUBSCRIPTIONS_VIEW_ALL: "view_all",
|
||||
SUBSCRIPTIONS_VIEW_LATEST_FIRST: "view_latest_first",
|
||||
|
||||
PLAY_STORE_URL: "https://play.google.com/store/apps/details?id=io.lbry.browser",
|
||||
RATING_REMINDER_INTERVAL: 604800, // 7 days (7 * 24 * 3600s)
|
||||
};
|
||||
|
||||
export default Constants;
|
||||
|
||||
export const DrawerRoutes = [
|
||||
Constants.DRAWER_ROUTE_DISCOVER,
|
||||
Constants.DRAWER_ROUTE_TRENDING,
|
||||
Constants.DRAWER_ROUTE_SUBSCRIPTIONS,
|
||||
Constants.DRAWER_ROUTE_MY_LBRY,
|
||||
Constants.DRAWER_ROUTE_REWARDS,
|
||||
Constants.DRAWER_ROUTE_WALLET,
|
||||
Constants.DRAWER_ROUTE_SETTINGS,
|
||||
Constants.DRAWER_ROUTE_ABOUT,
|
||||
Constants.DRAWER_ROUTE_SEARCH,
|
||||
Constants.DRAWER_ROUTE_TRANSACTION_HISTORY
|
||||
];
|
||||
+36
-18
@@ -1,36 +1,52 @@
|
||||
import React from 'react';
|
||||
import { setJSExceptionHandler } from 'react-native-exception-handler';
|
||||
import { Provider, connect } from 'react-redux';
|
||||
import {
|
||||
AppRegistry,
|
||||
AppState,
|
||||
AsyncStorage,
|
||||
Text,
|
||||
View,
|
||||
NativeModules
|
||||
} from 'react-native';
|
||||
import {
|
||||
Lbry,
|
||||
blacklistReducer,
|
||||
claimsReducer,
|
||||
costInfoReducer,
|
||||
contentReducer,
|
||||
fileReducer,
|
||||
fileInfoReducer,
|
||||
notificationsReducer,
|
||||
searchReducer,
|
||||
walletReducer
|
||||
} from 'lbry-redux';
|
||||
import { authReducer, rewardsReducer, userReducer } from 'lbryinc';
|
||||
import {
|
||||
authReducer,
|
||||
blacklistReducer,
|
||||
costInfoReducer,
|
||||
homepageReducer,
|
||||
rewardsReducer,
|
||||
subscriptionsReducer,
|
||||
syncReducer,
|
||||
userReducer
|
||||
} from 'lbryinc';
|
||||
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
|
||||
import { createLogger } from 'redux-logger';
|
||||
import { AppNavigator } from './component/AppNavigator';
|
||||
import AppWithNavigationState, { AppNavigator, navigatorReducer, reactNavigationMiddleware } from 'component/AppNavigator';
|
||||
import { persistStore, autoRehydrate } from 'redux-persist';
|
||||
import AppWithNavigationState, { reactNavigationMiddleware } from './component/AppNavigator';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import FilesystemStorage from 'redux-persist-filesystem-storage';
|
||||
import createCompressor from 'redux-persist-transform-compress';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
import moment from 'moment';
|
||||
import settingsReducer from './redux/reducers/settings';
|
||||
import drawerReducer from 'redux/reducers/drawer';
|
||||
import settingsReducer from 'redux/reducers/settings';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
|
||||
const globalExceptionHandler = (error, isFatal) => {
|
||||
if (error && NativeModules.Firebase) {
|
||||
NativeModules.Firebase.logException(isFatal, error.message ? error.message : "No message", JSON.stringify(error));
|
||||
}
|
||||
};
|
||||
setJSExceptionHandler(globalExceptionHandler, true);
|
||||
|
||||
function isFunction(object) {
|
||||
return typeof object === 'function';
|
||||
}
|
||||
@@ -59,31 +75,32 @@ function enableBatching(reducer) {
|
||||
};
|
||||
}
|
||||
|
||||
const router = AppNavigator.router;
|
||||
/*const router = AppNavigator.router;
|
||||
const navAction = router.getActionForPathAndParams('FirstRun');
|
||||
const initialNavState = router.getStateForAction(navAction);
|
||||
const navigatorReducer = (state = initialNavState, action) => {
|
||||
const nextState = AppNavigator.router.getStateForAction(action, state);
|
||||
return nextState || state;
|
||||
};
|
||||
const initialNavState = router.getStateForAction(navAction);*/
|
||||
|
||||
const reducers = combineReducers({
|
||||
auth: authReducer,
|
||||
blacklist: blacklistReducer,
|
||||
claims: claimsReducer,
|
||||
content: contentReducer,
|
||||
costInfo: costInfoReducer,
|
||||
drawer: drawerReducer,
|
||||
file: fileReducer,
|
||||
fileInfo: fileInfoReducer,
|
||||
homepage: homepageReducer,
|
||||
nav: navigatorReducer,
|
||||
notifications: notificationsReducer,
|
||||
rewards: rewardsReducer,
|
||||
settings: settingsReducer,
|
||||
search: searchReducer,
|
||||
subscriptions: subscriptionsReducer,
|
||||
sync: syncReducer,
|
||||
user: userReducer,
|
||||
wallet: walletReducer
|
||||
});
|
||||
|
||||
const bulkThunk = createBulkThunkMiddleware();
|
||||
const logger = createLogger({ collapsed: true });
|
||||
const middleware = [thunk, bulkThunk, reactNavigationMiddleware];
|
||||
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
@@ -101,13 +118,14 @@ window.store = store;
|
||||
|
||||
const compressor = createCompressor();
|
||||
const authFilter = createFilter('auth', ['authToken']);
|
||||
const contentFilter = createFilter('content', ['positions']);
|
||||
const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['subscriptions']);
|
||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||
|
||||
const persistOptions = {
|
||||
whitelist: ['auth', 'claims', 'subscriptions', 'settings', 'wallet'],
|
||||
whitelist: ['auth', 'claims', 'content', 'subscriptions', 'settings', 'wallet'],
|
||||
// Order is important. Needs to be compressed last or other transforms can't
|
||||
// read the data
|
||||
transforms: [authFilter, saveClaimsFilter, subscriptionsFilter, settingsFilter, walletFilter, compressor],
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import { doFetchAccessToken, selectAccessToken, selectUserEmail } from 'lbryinc';
|
||||
import { doPushDrawerStack, doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute, selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import AboutPage from './view';
|
||||
import Constants from 'constants';
|
||||
|
||||
const perform = dispatch => ({});
|
||||
const select = state => ({
|
||||
accessToken: selectAccessToken(state),
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
userEmail: selectUserEmail(state),
|
||||
});
|
||||
|
||||
export default connect(null, perform)(AboutPage);
|
||||
const perform = dispatch => ({
|
||||
fetchAccessToken: () => dispatch(doFetchAccessToken()),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_ABOUT)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(AboutPage);
|
||||
+71
-13
@@ -1,9 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import { NativeModules, Text, View, ScrollView } from 'react-native';
|
||||
import Link from '../../component/link';
|
||||
import PageHeader from '../../component/pageHeader';
|
||||
import aboutStyle from '../../styles/about';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import Constants from 'constants';
|
||||
import Link from 'component/link';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import aboutStyle from 'styles/about';
|
||||
|
||||
class AboutPage extends React.PureComponent {
|
||||
state = {
|
||||
@@ -12,7 +14,36 @@ class AboutPage extends React.PureComponent {
|
||||
versionInfo: null
|
||||
};
|
||||
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.DRAWER_ROUTE_ABOUT === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
|
||||
if (NativeModules.VersionInfo) {
|
||||
NativeModules.VersionInfo.getAppVersion().then(version => {
|
||||
this.setState({appVersion: version});
|
||||
@@ -28,17 +59,19 @@ class AboutPage extends React.PureComponent {
|
||||
lbryId: info.installation_id,
|
||||
});
|
||||
});
|
||||
|
||||
if (!this.props.accessToken) this.props.fetchAccessToken();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { navigation } = this.props;
|
||||
const { accessToken, drawerStack, navigation, notify, popDrawerStack, userEmail } = this.props;
|
||||
const loading = 'Loading...';
|
||||
const ver = this.state.versionInfo ? this.state.versionInfo : null;
|
||||
|
||||
return (
|
||||
<View style={aboutStyle.container}>
|
||||
<PageHeader title={"About LBRY"}
|
||||
onBackPressed={() => navigation.goBack(navigation.state.key)} />
|
||||
onBackPressed={() => navigateBack(navigation, drawerStack, popDrawerStack)} />
|
||||
<ScrollView style={aboutStyle.scrollContainer}>
|
||||
<Text style={aboutStyle.title}>Content Freedom</Text>
|
||||
<Text style={aboutStyle.paragraph}>
|
||||
@@ -48,8 +81,9 @@ class AboutPage extends React.PureComponent {
|
||||
digital content they are interested in.
|
||||
</Text>
|
||||
<View style={aboutStyle.links}>
|
||||
<Link style={aboutStyle.link} href="https://lbry.io/faq/what-is-lbry" text="What is LBRY?" />
|
||||
<Link style={aboutStyle.link} href="https://lbry.io/faq" text="Frequently Asked Questions" />
|
||||
<Link style={aboutStyle.link} href="https://lbry.com/faq/what-is-lbry" text="What is LBRY?" />
|
||||
<Link style={aboutStyle.link} href="https://lbry.com/faq/android-basics" text="Android App Basics" />
|
||||
<Link style={aboutStyle.link} href="https://lbry.com/faq" text="Frequently Asked Questions" />
|
||||
</View>
|
||||
<Text style={aboutStyle.socialTitle}>Get Social</Text>
|
||||
<Text style={aboutStyle.paragraph}>
|
||||
@@ -63,7 +97,21 @@ class AboutPage extends React.PureComponent {
|
||||
<Link style={aboutStyle.link} href="https://reddit.com/r/lbry" text="Reddit" />
|
||||
<Link style={aboutStyle.link} href="https://t.me/lbryofficial" text="Telegram" />
|
||||
</View>
|
||||
<Text style={aboutStyle.releaseInfoTitle}>Release information</Text>
|
||||
<Text style={aboutStyle.releaseInfoTitle}>App info</Text>
|
||||
{userEmail && userEmail.trim().length > 0 &&
|
||||
<View style={aboutStyle.verticalRow}>
|
||||
<View style={aboutStyle.innerRow}>
|
||||
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Connected Email</Text></View>
|
||||
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{userEmail}</Text></View>
|
||||
</View>
|
||||
<View>
|
||||
<Link
|
||||
style={aboutStyle.listLink}
|
||||
href={`http://lbry.com/list/edit/${accessToken}`}
|
||||
text="Update mailing preferences" />
|
||||
</View>
|
||||
</View>}
|
||||
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}><Text style={aboutStyle.text}>App version</Text></View>
|
||||
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{this.state.appVersion}</Text></View>
|
||||
@@ -74,11 +122,6 @@ class AboutPage extends React.PureComponent {
|
||||
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.lbrynet_version : loading }</Text></View>
|
||||
</View>
|
||||
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Wallet (lbryum)</Text></View>
|
||||
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.lbryum_version : loading }</Text></View>
|
||||
</View>
|
||||
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Platform</Text></View>
|
||||
<View style={aboutStyle.col}><Text selectable={true} style={aboutStyle.valueText}>{ver ? ver.platform : loading }</Text></View>
|
||||
@@ -90,6 +133,21 @@ class AboutPage extends React.PureComponent {
|
||||
<Text selectable={true} style={aboutStyle.lineValueText}>{this.state.lbryId ? this.state.lbryId : loading}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={aboutStyle.row}>
|
||||
<View style={aboutStyle.col}><Text style={aboutStyle.text}>Logs</Text></View>
|
||||
<View style={aboutStyle.col}>
|
||||
<Link style={aboutStyle.listLink} text="Send log" onPress={() => {
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.shareLogFile((error) => {
|
||||
if (error) {
|
||||
notify(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}} />
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchClaimsByChannel,
|
||||
doFetchClaimCountByChannel,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectClaimsInChannelForPage,
|
||||
makeSelectClaimsInChannelForCurrentPageState,
|
||||
makeSelectFetchingChannelClaims,
|
||||
makeSelectTotalPagesForChannel
|
||||
} from 'lbry-redux';
|
||||
import { doPopDrawerStack } from 'redux/actions/drawer';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import ChannelPage from './view';
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: makeSelectClaimForUri(props.uri)(state),
|
||||
claimsInChannel: makeSelectClaimsInChannelForPage(props.uri, props.page || 1)(state),
|
||||
claimsInChannel: makeSelectClaimsInChannelForCurrentPageState(props.uri)(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
fetching: makeSelectFetchingChannelClaims(props.uri)(state),
|
||||
totalPages: makeSelectTotalPagesForChannel(props.uri, 10)(state), // Update to use a default PAGE_SIZE constant
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchClaims: (uri, page) => dispatch(doFetchClaimsByChannel(uri, page)),
|
||||
fetchClaimCount: uri => dispatch(doFetchClaimCountByChannel(uri)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack())
|
||||
});
|
||||
|
||||
export default connect(select, perform)(ChannelPage);
|
||||
+181
-14
@@ -1,25 +1,61 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import { ActivityIndicator, Text, View } from 'react-native';
|
||||
import Colors from '../../styles/colors';
|
||||
import FileList from '../../component/fileList';
|
||||
import PageHeader from '../../component/pageHeader';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import channelPageStyle from '../../styles/channelPage';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Dimensions,
|
||||
Image,
|
||||
ScrollView,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { TabView, SceneMap } from 'react-native-tab-view';
|
||||
import { navigateBack } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Button from 'component/button';
|
||||
import Link from 'component/link';
|
||||
import FileList from 'component/fileList';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import UriBar from 'component/uriBar';
|
||||
import channelPageStyle from 'styles/channelPage';
|
||||
|
||||
class ChannelPage extends React.PureComponent {
|
||||
state = {
|
||||
page: 1,
|
||||
showPageButtons: false,
|
||||
activeTab: Constants.CONTENT_TAB
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
const { uri, page, claimsInChannel, fetchClaims, fetchClaimCount } = this.props;
|
||||
|
||||
if (!claimsInChannel || !claimsInChannel.length) {
|
||||
fetchClaims(uri, page || 1);
|
||||
fetchClaimCount(uri);
|
||||
fetchClaims(uri, page || this.state.page);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { fetching, claimsInChannel, claim, navigation, uri } = this.props;
|
||||
const { name, permanent_url: permanentUrl } = claim;
|
||||
handlePreviousPage = () => {
|
||||
const { uri, fetchClaims } = this.props;
|
||||
if (this.state.page > 1) {
|
||||
this.setState({ page: this.state.page - 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleNextPage = () => {
|
||||
const { uri, fetchClaims, totalPages } = this.props;
|
||||
if (this.state.page < totalPages) {
|
||||
this.setState({ page: this.state.page + 1, showPageButtons: false }, () => {
|
||||
fetchClaims(uri, this.state.page);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
renderContent = () => {
|
||||
const { fetching, claimsInChannel, totalPages, navigation } = this.props;
|
||||
|
||||
let contentList;
|
||||
if (fetching) {
|
||||
@@ -36,7 +72,9 @@ class ChannelPage extends React.PureComponent {
|
||||
hideFilter
|
||||
fileInfos={claimsInChannel}
|
||||
navigation={navigation}
|
||||
style={channelPageStyle.fileList} />
|
||||
style={channelPageStyle.fileList}
|
||||
contentContainerStyle={channelPageStyle.fileListContent}
|
||||
onEndReached={() => this.setState({ showPageButtons: true })} />
|
||||
) : (
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>No content found.</Text>
|
||||
@@ -44,12 +82,141 @@ class ChannelPage extends React.PureComponent {
|
||||
);
|
||||
}
|
||||
|
||||
let pageButtons;
|
||||
if (totalPages > 1 && this.state.showPageButtons) {
|
||||
pageButtons = (
|
||||
<View style={channelPageStyle.pageButtons}>
|
||||
<View>
|
||||
{(this.state.page > 1) && <Button
|
||||
style={channelPageStyle.button}
|
||||
text={"Previous"}
|
||||
disabled={!!fetching}
|
||||
onPress={this.handlePreviousPage} />}
|
||||
</View>
|
||||
{(this.state.page < totalPages) && <Button
|
||||
style={[channelPageStyle.button, channelPageStyle.nextButton]}
|
||||
text={"Next"}
|
||||
disabled={!!fetching}
|
||||
onPress={this.handleNextPage} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={channelPageStyle.contentTab}>
|
||||
{contentList}
|
||||
{pageButtons}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
renderAbout = () => {
|
||||
const { claim } = this.props;
|
||||
|
||||
if (!claim) {
|
||||
return (
|
||||
<View style={channelPageStyle.aboutTab}>
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>No information to display.</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const { cover, description, thumbnail, email, website_url, title } = claim.value;
|
||||
return (
|
||||
<View style={channelPageStyle.aboutTab}>
|
||||
{(!website_url && !email && !description) &&
|
||||
<View style={channelPageStyle.busyContainer}>
|
||||
<Text style={channelPageStyle.infoText}>Nothing here yet. Please check back later.</Text>
|
||||
</View>}
|
||||
|
||||
{(website_url || email || description) &&
|
||||
<ScrollView style={channelPageStyle.aboutScroll} contentContainerStyle={channelPageStyle.aboutScrollContent}>
|
||||
{(website_url && website_url.trim().length > 0) &&
|
||||
<View style={channelPageStyle.aboutItem}>
|
||||
<Text style={channelPageStyle.aboutTitle}>Website</Text>
|
||||
<Link style={channelPageStyle.aboutText} text={website_url} href={website_url} />
|
||||
</View>}
|
||||
|
||||
{(email && email.trim().length > 0) &&
|
||||
<View style={channelPageStyle.aboutItem}>
|
||||
<Text style={channelPageStyle.aboutTitle}>Email</Text>
|
||||
<Link style={channelPageStyle.aboutText} text={email} href={`mailto:${email}`} />
|
||||
</View>}
|
||||
|
||||
{(description && description.trim().length > 0) &&
|
||||
<View style={channelPageStyle.aboutItem}>
|
||||
<Text style={channelPageStyle.aboutText}>{description}</Text>
|
||||
</View>}
|
||||
</ScrollView>}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
fetching,
|
||||
claimsInChannel,
|
||||
claim,
|
||||
navigation,
|
||||
totalPages,
|
||||
uri,
|
||||
drawerStack,
|
||||
popDrawerStack
|
||||
} = this.props;
|
||||
const { name, permanent_url: permanentUrl } = claim;
|
||||
|
||||
let thumbnailUrl, coverUrl, title;
|
||||
if (claim && claim.value) {
|
||||
title = claim.value.title;
|
||||
if (claim.value.cover) {
|
||||
coverUrl = claim.value.cover.url;
|
||||
}
|
||||
if (claim.value.thumbnail) {
|
||||
thumbnailUrl = claim.value.thumbnail.url;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={channelPageStyle.container}>
|
||||
<PageHeader title={name} onBackPressed={() => navigation.goBack(navigation.state.key)} />
|
||||
{contentList}
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
|
||||
<View style={channelPageStyle.viewContainer}>
|
||||
<View style={channelPageStyle.cover}>
|
||||
<Image
|
||||
style={channelPageStyle.coverImage}
|
||||
resizeMode={'cover'}
|
||||
source={(coverUrl && coverUrl.trim().length > 0) ? { uri: coverUrl } : require('../../assets/default_channel_cover.png')} />
|
||||
|
||||
<View style={channelPageStyle.channelHeader}>
|
||||
<Text style={channelPageStyle.channelName}>{(title && title.trim().length > 0) ? title : name}</Text>
|
||||
</View>
|
||||
|
||||
<View style={channelPageStyle.avatarImageContainer}>
|
||||
<Image
|
||||
style={channelPageStyle.avatarImage}
|
||||
resizeMode={'cover'}
|
||||
source={(thumbnailUrl && thumbnailUrl.trim().length > 0) ? { uri: thumbnailUrl } : require('../../assets/default_avatar.jpg')} />
|
||||
</View>
|
||||
|
||||
<SubscribeButton style={channelPageStyle.subscribeButton} uri={uri} name={name} />
|
||||
</View>
|
||||
|
||||
<View style={channelPageStyle.tabBar}>
|
||||
<TouchableOpacity style={channelPageStyle.tab} onPress={() => this.setState({ activeTab: Constants.CONTENT_TAB })}>
|
||||
<Text style={channelPageStyle.tabTitle}>CONTENT</Text>
|
||||
{Constants.CONTENT_TAB === this.state.activeTab && <View style={channelPageStyle.activeTabHint} />}
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={channelPageStyle.tab} onPress={() => this.setState({ activeTab: Constants.ABOUT_TAB })}>
|
||||
<Text style={channelPageStyle.tabTitle}>ABOUT</Text>
|
||||
{Constants.ABOUT_TAB === this.state.activeTab && <View style={channelPageStyle.activeTabHint} />}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
|
||||
{Constants.CONTENT_TAB === this.state.activeTab && this.renderContent()}
|
||||
{Constants.ABOUT_TAB === this.state.activeTab && this.renderAbout()}
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,22 +1,44 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchFeaturedUris,
|
||||
doFileList,
|
||||
selectBalance,
|
||||
selectFeaturedUris,
|
||||
selectFetchingFeaturedUris
|
||||
selectFileInfosDownloaded,
|
||||
} from 'lbry-redux';
|
||||
import { doFetchRewardedContent } from 'lbryinc';
|
||||
import {
|
||||
doFetchFeaturedUris,
|
||||
doFetchRewardedContent,
|
||||
doFetchMySubscriptions,
|
||||
doRemoveUnreadSubscriptions,
|
||||
selectEnabledChannelNotifications,
|
||||
selectFeaturedUris,
|
||||
selectFetchingFeaturedUris,
|
||||
selectSubscriptionClaims,
|
||||
selectUnreadSubscriptions,
|
||||
} from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import Constants from 'constants';
|
||||
import DiscoverPage from './view';
|
||||
|
||||
const select = state => ({
|
||||
allSubscriptions: selectSubscriptionClaims(state),
|
||||
balance: selectBalance(state),
|
||||
enabledChannelNotifications: selectEnabledChannelNotifications(state),
|
||||
featuredUris: selectFeaturedUris(state),
|
||||
fetchingFeaturedUris: selectFetchingFeaturedUris(state),
|
||||
fileInfos: selectFileInfosDownloaded(state),
|
||||
ratingReminderDisabled: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED)(state),
|
||||
ratingReminderLastShown: makeSelectClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN)(state),
|
||||
unreadSubscriptions: selectUnreadSubscriptions(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fetchFeaturedUris: () => dispatch(doFetchFeaturedUris()),
|
||||
fetchRewardedContent: () => dispatch(doFetchRewardedContent()),
|
||||
fetchSubscriptions: () => dispatch(doFetchMySubscriptions()),
|
||||
fileList: () => dispatch(doFileList()),
|
||||
removeUnreadSubscriptions: () => dispatch(doRemoveUnreadSubscriptions()),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(DiscoverPage);
|
||||
export default connect(select, perform)(DiscoverPage);
|
||||
+138
-26
@@ -1,21 +1,23 @@
|
||||
import React from 'react';
|
||||
import NavigationActions from 'react-navigation';
|
||||
import {
|
||||
Alert,
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Linking,
|
||||
NativeModules,
|
||||
SectionList,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
import { normalizeURI } from 'lbry-redux';
|
||||
import { Lbry, normalizeURI, parseURI } from 'lbry-redux';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import moment from 'moment';
|
||||
import Colors from '../../styles/colors';
|
||||
import discoverStyle from '../../styles/discover';
|
||||
import FloatingWalletBalance from '../../component/floatingWalletBalance';
|
||||
import FileItem from '../../component/fileItem';
|
||||
import RewardSummary from '../../component/rewardSummary';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import CategoryList from 'component/categoryList';
|
||||
import Constants from 'constants';
|
||||
import Colors from 'styles/colors';
|
||||
import discoverStyle from 'styles/discover';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import UriBar from 'component/uriBar';
|
||||
|
||||
class DiscoverPage extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
@@ -32,18 +34,126 @@ class DiscoverPage extends React.PureComponent {
|
||||
AsyncStorage.getItem('firstLaunchSuspended').then(suspended => {
|
||||
AsyncStorage.removeItem('firstLaunchSuspended');
|
||||
const appSuspended = (suspended === 'true');
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('First Run Time', {
|
||||
'Total Seconds': delta, 'App Suspended': appSuspended
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('first_run_time', {
|
||||
'total_seconds': delta, 'app_suspended': appSuspended
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const { fetchFeaturedUris, fetchRewardedContent } = this.props;
|
||||
const {
|
||||
fetchFeaturedUris,
|
||||
fetchRewardedContent,
|
||||
fetchSubscriptions,
|
||||
fileList
|
||||
} = this.props;
|
||||
|
||||
fetchFeaturedUris();
|
||||
fetchRewardedContent();
|
||||
fetchSubscriptions();
|
||||
fileList();
|
||||
|
||||
this.showRatingReminder();
|
||||
}
|
||||
|
||||
subscriptionForUri = (uri, channelName) => {
|
||||
const { allSubscriptions } = this.props;
|
||||
const { claimId, claimName } = parseURI(uri);
|
||||
|
||||
if (allSubscriptions) {
|
||||
for (let i = 0; i < allSubscriptions.length; i++) {
|
||||
const sub = allSubscriptions[i];
|
||||
|
||||
if (sub.claim_id === claimId && sub.name === claimName && sub.channel_name === channelName) {
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||
|
||||
const utility = NativeModules.UtilityModule;
|
||||
if (utility) {
|
||||
const hasUnread = prevProps.unreadSubscriptions &&
|
||||
prevProps.unreadSubscriptions.length !== unreadSubscriptions.length &&
|
||||
unreadSubscriptions.length > 0;
|
||||
|
||||
if (hasUnread) {
|
||||
unreadSubscriptions.map(({ channel, uris }) => {
|
||||
const { claimName: channelName } = parseURI(channel);
|
||||
|
||||
// check if notifications are enabled for the channel
|
||||
if (enabledChannelNotifications.indexOf(channelName) > -1) {
|
||||
uris.forEach(uri => {
|
||||
Lbry.resolve({ urls: uri }).then(result => {
|
||||
const sub = result[uri].claim;
|
||||
if (sub && sub.value && sub.value.stream) {
|
||||
let isPlayable = false;
|
||||
const source = sub.value.stream.source;
|
||||
const metadata = sub.value.stream.metadata;
|
||||
if (source) {
|
||||
isPlayable = source.contentType && ['audio', 'video'].indexOf(source.contentType.substring(0, 5)) > -1;
|
||||
}
|
||||
if (metadata) {
|
||||
utility.showNotificationForContent(uri, metadata.title, channelName, metadata.thumbnail, isPlayable);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showRatingReminder = () => {
|
||||
const { ratingReminderDisabled, ratingReminderLastShown, setClientSetting } = this.props;
|
||||
|
||||
const now = moment().unix();
|
||||
if ('true' !== ratingReminderDisabled && ratingReminderLastShown) {
|
||||
const lastShownParts = ratingReminderLastShown.split('|');
|
||||
if (lastShownParts.length === 2) {
|
||||
const lastShownTime = parseInt(lastShownParts[0], 10);
|
||||
const lastShownCount = parseInt(lastShownParts[1], 10);
|
||||
if (!isNaN(lastShownTime) && !isNaN(lastShownCount)) {
|
||||
if (now > (lastShownTime + (Constants.RATING_REMINDER_INTERVAL * lastShownCount))) {
|
||||
Alert.alert(
|
||||
'Enjoying LBRY?',
|
||||
'Are you enjoying your experience with the LBRY app? You can leave a review for us on the Play Store.',
|
||||
[
|
||||
{ text: 'Never ask again', onPress: () => setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true')},
|
||||
{ text: 'Maybe later', onPress: () => this.updateRatingReminderShown(lastShownCount)},
|
||||
{ text: 'Rate app', onPress: () => {
|
||||
setClientSetting(Constants.SETTING_RATING_REMINDER_DISABLED, 'true');
|
||||
Linking.openURL(Constants.PLAY_STORE_URL);
|
||||
}}
|
||||
],
|
||||
{ cancelable: false }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ratingReminderLastShown) {
|
||||
// first time, so set a value for the next interval multiplier
|
||||
this.updateRatingReminderShown(0);
|
||||
}
|
||||
}
|
||||
|
||||
updateRatingReminderShown = (lastShownCount) => {
|
||||
const { setClientSetting } = this.props;
|
||||
const settingString = (moment().unix() + '|' + (lastShownCount + 1));
|
||||
setClientSetting(Constants.SETTING_RATING_REMINDER_LAST_SHOWN, settingString);
|
||||
}
|
||||
|
||||
trimClaimIdFromCategory(category) {
|
||||
return category.split('#')[0];
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -53,33 +163,35 @@ class DiscoverPage extends React.PureComponent {
|
||||
|
||||
return (
|
||||
<View style={discoverStyle.container}>
|
||||
<RewardSummary navigation={navigation} />
|
||||
<UriBar navigation={navigation} />
|
||||
{!hasContent && fetchingFeaturedUris && (
|
||||
<View style={discoverStyle.busyContainer}>
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} />
|
||||
<Text style={discoverStyle.title}>Fetching content...</Text>
|
||||
</View>
|
||||
)}
|
||||
{hasContent &&
|
||||
<SectionList style={discoverStyle.scrollContainer}
|
||||
{(!!hasContent) &&
|
||||
(<SectionList
|
||||
style={discoverStyle.scrollContainer}
|
||||
contentContainerStyle={discoverStyle.scrollPadding}
|
||||
initialNumToRender={4}
|
||||
maxToRenderPerBatch={4}
|
||||
removeClippedSubviews={true}
|
||||
renderItem={ ({item, index, section}) => (
|
||||
<FileItem
|
||||
style={discoverStyle.fileItem}
|
||||
mediaStyle={discoverStyle.fileItemMedia}
|
||||
key={item}
|
||||
uri={normalizeURI(item)}
|
||||
navigation={navigation} />
|
||||
)
|
||||
}
|
||||
<CategoryList
|
||||
key={item}
|
||||
category={item}
|
||||
categoryMap={featuredUris}
|
||||
navigation={navigation} />
|
||||
)}
|
||||
renderSectionHeader={
|
||||
({section: {title}}) => (<Text style={discoverStyle.categoryName}>{title}</Text>)
|
||||
}
|
||||
sections={Object.keys(featuredUris).map(category => ({ title: category, data: featuredUris[category] }))}
|
||||
sections={Object.keys(featuredUris).map(category => ({ title: this.trimClaimIdFromCategory(category), data: [category] }))}
|
||||
keyExtractor={(item, index) => item}
|
||||
/>
|
||||
/>)
|
||||
}
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
<UriBar navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,16 +5,22 @@ import {
|
||||
selectMyClaimsWithoutChannels,
|
||||
selectIsFetchingFileList,
|
||||
} from 'lbry-redux';
|
||||
import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectCurrentRoute } from 'redux/selectors/drawer';
|
||||
import Constants from 'constants';
|
||||
import DownloadsPage from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
claims: selectMyClaimsWithoutChannels(state),
|
||||
currentRoute: selectCurrentRoute(state),
|
||||
fileInfos: selectFileInfosDownloaded(state),
|
||||
fetching: selectIsFetchingFileList(state),
|
||||
claims: selectMyClaimsWithoutChannels(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
fileList: () => dispatch(doFileList()),
|
||||
pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_MY_LBRY)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(false))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(DownloadsPage);
|
||||
@@ -9,31 +9,52 @@ import {
|
||||
View,
|
||||
ScrollView
|
||||
} from 'react-native';
|
||||
import { navigateToUri } from '../../utils/helper';
|
||||
import Colors from '../../styles/colors';
|
||||
import PageHeader from '../../component/pageHeader';
|
||||
import FileListItem from '../../component/fileListItem';
|
||||
import FloatingWalletBalance from '../../component/floatingWalletBalance';
|
||||
import StorageStatsCard from '../../component/storageStatsCard';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import downloadsStyle from '../../styles/downloads';
|
||||
import fileListStyle from '../../styles/fileList';
|
||||
import { navigateToUri, uriFromFileInfo } from 'utils/helper';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import PageHeader from 'component/pageHeader';
|
||||
import FileListItem from 'component/fileListItem';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import StorageStatsCard from 'component/storageStatsCard';
|
||||
import UriBar from 'component/uriBar';
|
||||
import downloadsStyle from 'styles/downloads';
|
||||
import fileListStyle from 'styles/fileList';
|
||||
|
||||
class DownloadsPage extends React.PureComponent {
|
||||
static navigationOptions = {
|
||||
title: 'My LBRY'
|
||||
title: 'Downloads'
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fileList();
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
uriFromFileInfo(fileInfo) {
|
||||
const { name: claimName, claim_name: claimNameDownloaded, claim_id: claimId } = fileInfo;
|
||||
const uriParams = {};
|
||||
uriParams.contentName = claimName || claimNameDownloaded;
|
||||
uriParams.claimId = claimId;
|
||||
return buildURI(uriParams);
|
||||
componentWillUnmount() {
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
const { fileList, pushDrawerStack, setPlayerVisible } = this.props;
|
||||
pushDrawerStack();
|
||||
setPlayerVisible();
|
||||
fileList();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { currentRoute } = nextProps;
|
||||
const { currentRoute: prevRoute } = this.props;
|
||||
if (Constants.FULL_ROUTE_NAME_MY_LBRY === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -42,9 +63,10 @@ class DownloadsPage extends React.PureComponent {
|
||||
|
||||
return (
|
||||
<View style={downloadsStyle.container}>
|
||||
<UriBar navigation={navigation} />
|
||||
{!fetching && !hasDownloads &&
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
<Text style={downloadsStyle.noDownloadsText}>You have not downloaded anything from LBRY yet.</Text>
|
||||
<Text style={downloadsStyle.noDownloadsText}>You have not watched or downloaded any content from LBRY yet.</Text>
|
||||
</View>}
|
||||
{fetching && !hasDownloads &&
|
||||
<View style={downloadsStyle.busyContainer}>
|
||||
@@ -59,23 +81,16 @@ class DownloadsPage extends React.PureComponent {
|
||||
renderItem={ ({item}) => (
|
||||
<FileListItem
|
||||
style={fileListStyle.item}
|
||||
uri={this.uriFromFileInfo(item)}
|
||||
uri={uriFromFileInfo(item)}
|
||||
navigation={navigation}
|
||||
onPress={() => navigateToUri(navigation, this.uriFromFileInfo(item), { autoplay: true })} />
|
||||
onPress={() => navigateToUri(navigation, uriFromFileInfo(item), { autoplay: true })} />
|
||||
)
|
||||
}
|
||||
data={fileInfos.sort((a, b) => {
|
||||
// TODO: Implement sort based on user selection
|
||||
if (!a.completed && b.completed) return -1;
|
||||
if (a.completed && !b.completed) return 1;
|
||||
if (a.metadata.title === b.metadata.title) return 0;
|
||||
return (a.metadata.title < b.metadata.title) ? -1 : 1;
|
||||
})}
|
||||
data={fileInfos}
|
||||
keyExtractor={(item, index) => item.outpoint}
|
||||
/>
|
||||
</View>}
|
||||
<FloatingWalletBalance navigation={navigation} />
|
||||
<UriBar navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,50 @@
|
||||
import { connect } from 'react-redux';
|
||||
import {
|
||||
doFetchFileInfo,
|
||||
doFetchCostInfoForUri,
|
||||
doPurchaseUri,
|
||||
doDeletePurchasedUri,
|
||||
doResolveUri,
|
||||
doNotify,
|
||||
doSendTip,
|
||||
doToast,
|
||||
makeSelectIsUriResolving,
|
||||
makeSelectCostInfoForUri,
|
||||
makeSelectFileInfoForUri,
|
||||
makeSelectChannelForClaimUri,
|
||||
makeSelectClaimForUri,
|
||||
makeSelectContentPositionForUri,
|
||||
makeSelectContentTypeForUri,
|
||||
makeSelectMetadataForUri,
|
||||
selectBlackListedOutpoints,
|
||||
makeSelectStreamingUrlForUri,
|
||||
makeSelectThumbnailForUri,
|
||||
makeSelectTitleForUri,
|
||||
selectBalance,
|
||||
selectPurchasedUris,
|
||||
selectFailedPurchaseUris,
|
||||
selectPurchaseUriErrorMessage,
|
||||
} from 'lbry-redux';
|
||||
import { selectRewardContentClaimIds } from 'lbryinc';
|
||||
import { doDeleteFile, doStopDownloadingFile } from '../../redux/actions/file';
|
||||
import {
|
||||
doFetchCostInfoForUri,
|
||||
makeSelectCostInfoForUri,
|
||||
selectRewardContentClaimIds,
|
||||
selectBlackListedOutpoints
|
||||
} from 'lbryinc';
|
||||
import {
|
||||
doStartDownload,
|
||||
doUpdateDownload,
|
||||
doCompleteDownload,
|
||||
doDeleteFile,
|
||||
doStopDownloadingFile
|
||||
} from 'redux/actions/file';
|
||||
import { doPopDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer';
|
||||
import { selectDrawerStack } from 'redux/selectors/drawer';
|
||||
import FilePage from './view';
|
||||
|
||||
const select = (state, props) => {
|
||||
const selectProps = { uri: props.navigation.state.params.uri };
|
||||
return {
|
||||
balance: selectBalance(state),
|
||||
blackListedOutpoints: selectBlackListedOutpoints(state),
|
||||
claim: makeSelectClaimForUri(selectProps.uri)(state),
|
||||
drawerStack: selectDrawerStack(state),
|
||||
isResolvingUri: makeSelectIsUriResolving(selectProps.uri)(state),
|
||||
contentType: makeSelectContentTypeForUri(selectProps.uri)(state),
|
||||
costInfo: makeSelectCostInfoForUri(selectProps.uri)(state),
|
||||
@@ -29,6 +53,14 @@ const select = (state, props) => {
|
||||
//tab: makeSelectCurrentParam('tab')(state),
|
||||
fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state),
|
||||
rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps),
|
||||
channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state),
|
||||
position: makeSelectContentPositionForUri(selectProps.uri)(state),
|
||||
purchasedUris: selectPurchasedUris(state),
|
||||
failedPurchaseUris: selectFailedPurchaseUris(state),
|
||||
purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state),
|
||||
streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state),
|
||||
thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state),
|
||||
title: makeSelectTitleForUri(selectProps.uri)(state),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -38,9 +70,17 @@ const perform = dispatch => ({
|
||||
},
|
||||
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
|
||||
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
|
||||
notify: data => dispatch(doNotify(data)),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
popDrawerStack: () => dispatch(doPopDrawerStack()),
|
||||
purchaseUri: (uri, costInfo, saveFile) => dispatch(doPurchaseUri(uri, costInfo, saveFile)),
|
||||
deletePurchasedUri: uri => dispatch(doDeletePurchasedUri(uri)),
|
||||
resolveUri: uri => dispatch(doResolveUri(uri)),
|
||||
sendTip: (amount, claimId, uri, successCallback, errorCallback) => dispatch(doSendTip(amount, claimId, uri, successCallback, errorCallback)),
|
||||
setPlayerVisible: () => dispatch(doSetPlayerVisible(true)),
|
||||
stopDownload: (uri, fileInfo) => dispatch(doStopDownloadingFile(uri, fileInfo)),
|
||||
startDownload: (uri, outpoint, fileInfo) => dispatch(doStartDownload(uri, outpoint, fileInfo)),
|
||||
updateDownload: (uri, outpoint, fileInfo, progress) => dispatch(doUpdateDownload(uri, outpoint, fileInfo, progress)),
|
||||
completeDownload: (uri, outpoint, fileInfo) => dispatch(doCompleteDownload(uri, outpoint, fileInfo)),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FilePage);
|
||||
+431
-131
@@ -4,6 +4,7 @@ import { Lbryio } from 'lbryinc';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
DeviceEventEmitter,
|
||||
Dimensions,
|
||||
NativeModules,
|
||||
ScrollView,
|
||||
@@ -12,39 +13,52 @@ import {
|
||||
Text,
|
||||
TextInput,
|
||||
TouchableOpacity,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
WebView
|
||||
} from 'react-native';
|
||||
import { navigateToUri } from '../../utils/helper';
|
||||
import { NavigationEvents } from 'react-navigation';
|
||||
import { navigateBack, navigateToUri } from 'utils/helper';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import ImageViewer from 'react-native-image-zoom-viewer';
|
||||
import Button from '../../component/button';
|
||||
import Colors from '../../styles/colors';
|
||||
import ChannelPage from '../channel';
|
||||
import FileDownloadButton from '../../component/fileDownloadButton';
|
||||
import FileItemMedia from '../../component/fileItemMedia';
|
||||
import FilePrice from '../../component/filePrice';
|
||||
import FloatingWalletBalance from '../../component/floatingWalletBalance';
|
||||
import Link from '../../component/link';
|
||||
import MediaPlayer from '../../component/mediaPlayer';
|
||||
import RelatedContent from '../../component/relatedContent';
|
||||
import UriBar from '../../component/uriBar';
|
||||
import Button from 'component/button';
|
||||
import ChannelPage from 'page/channel';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import DateTime from 'component/dateTime';
|
||||
import FileDownloadButton from 'component/fileDownloadButton';
|
||||
import FileItemMedia from 'component/fileItemMedia';
|
||||
import FilePrice from 'component/filePrice';
|
||||
import FloatingWalletBalance from 'component/floatingWalletBalance';
|
||||
import Link from 'component/link';
|
||||
import MediaPlayer from 'component/mediaPlayer';
|
||||
import RelatedContent from 'component/relatedContent';
|
||||
import SubscribeButton from 'component/subscribeButton';
|
||||
import SubscribeNotificationButton from 'component/subscribeNotificationButton';
|
||||
import UriBar from 'component/uriBar';
|
||||
import Video from 'react-native-video';
|
||||
import filePageStyle from '../../styles/filePage';
|
||||
import uriBarStyle from '../../styles/uriBar';
|
||||
import FileRewardsDriver from 'component/fileRewardsDriver';
|
||||
import filePageStyle from 'styles/filePage';
|
||||
import uriBarStyle from 'styles/uriBar';
|
||||
|
||||
class FilePage extends React.PureComponent {
|
||||
static navigationOptions = {
|
||||
title: ''
|
||||
};
|
||||
|
||||
tipAmountInput = null;
|
||||
|
||||
playerBackground = null;
|
||||
|
||||
scrollView = null;
|
||||
|
||||
startTime = null;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
autoPlayMedia: false,
|
||||
autoDownloadStarted: false,
|
||||
downloadButtonShown: false,
|
||||
downloadPressed: false,
|
||||
fileViewLogged: false,
|
||||
@@ -53,37 +67,112 @@ class FilePage extends React.PureComponent {
|
||||
isLandscape: false,
|
||||
mediaLoaded: false,
|
||||
pageSuspended: false,
|
||||
relatedContentY: 0,
|
||||
showDescription: false,
|
||||
showImageViewer: false,
|
||||
showWebView: false,
|
||||
showTipView: false,
|
||||
playerBgHeight: 0,
|
||||
playerHeight: 0,
|
||||
tipAmount: null,
|
||||
uri: null,
|
||||
stopDownloadConfirmed: false
|
||||
uriVars: null,
|
||||
stopDownloadConfirmed: false,
|
||||
streamingMode: false
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
didFocusListener;
|
||||
|
||||
componentWillMount() {
|
||||
const { navigation } = this.props;
|
||||
this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
|
||||
}
|
||||
|
||||
onComponentFocused = () => {
|
||||
StatusBar.setHidden(false);
|
||||
|
||||
const { isResolvingUri, resolveUri, navigation } = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
this.setState({ uri });
|
||||
DeviceEventEmitter.addListener('onDownloadStarted', this.handleDownloadStarted);
|
||||
DeviceEventEmitter.addListener('onDownloadUpdated', this.handleDownloadUpdated);
|
||||
DeviceEventEmitter.addListener('onDownloadCompleted', this.handleDownloadCompleted);
|
||||
|
||||
const { fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
|
||||
const { uri, uriVars } = navigation.state.params;
|
||||
this.setState({ uri, uriVars });
|
||||
|
||||
if (!isResolvingUri) resolveUri(uri);
|
||||
|
||||
this.fetchFileInfo(this.props);
|
||||
this.fetchCostInfo(this.props);
|
||||
|
||||
if (NativeModules.Mixpanel) {
|
||||
NativeModules.Mixpanel.track('Open File Page', { Uri: uri });
|
||||
if (NativeModules.Firebase) {
|
||||
NativeModules.Firebase.track('open_file_page', { uri: uri });
|
||||
}
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.keepAwakeOn();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const {
|
||||
claim,
|
||||
currentRoute,
|
||||
failedPurchaseUris: prevFailedPurchaseUris,
|
||||
purchasedUris: prevPurchasedUris,
|
||||
navigation,
|
||||
contentType,
|
||||
notify
|
||||
} = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
const {
|
||||
currentRoute: prevRoute,
|
||||
failedPurchaseUris,
|
||||
fileInfo,
|
||||
purchasedUris,
|
||||
purchaseUriErrorMessage,
|
||||
streamingUrl
|
||||
} = nextProps;
|
||||
|
||||
if (Constants.ROUTE_FILE === currentRoute && currentRoute !== prevRoute) {
|
||||
this.onComponentFocused();
|
||||
}
|
||||
|
||||
if (failedPurchaseUris.includes(uri) && !purchasedUris.includes(uri)) {
|
||||
if (purchaseUriErrorMessage && purchaseUriErrorMessage.trim().length > 0) {
|
||||
notify({ message: purchaseUriErrorMessage, isError: true });
|
||||
}
|
||||
this.setState({ downloadPressed: false, fileViewLogged: false, mediaLoaded: false });
|
||||
}
|
||||
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
if (prevPurchasedUris.length != purchasedUris.length && NativeModules.UtilityModule) {
|
||||
if (purchasedUris.includes(uri)) {
|
||||
const { nout, txid } = claim;
|
||||
const outpoint = `${txid}:${nout}`;
|
||||
NativeModules.UtilityModule.queueDownload(outpoint);
|
||||
// If the media is playable, file/view will be done in onPlaybackStarted
|
||||
if (!isPlayable && !this.state.fileViewLogged) {
|
||||
this.logFileView(uri, claim);
|
||||
}
|
||||
}
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
|
||||
if (!this.state.streamingMode && isPlayable) {
|
||||
if (streamingUrl) {
|
||||
this.setState({ streamingMode: true, currentStreamUrl: streamingUrl });
|
||||
} else if (fileInfo && fileInfo.streaming_url) {
|
||||
this.setState({ streamingMode: true, currentStreamUrl: fileInfo.streaming_url });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
this.fetchFileInfo(this.props);
|
||||
const { claim, contentType, fileInfo, isResolvingUri, resolveUri, navigation } = this.props;
|
||||
const { uri } = this.state;
|
||||
if (!isResolvingUri && claim === undefined && uri) {
|
||||
@@ -99,17 +188,6 @@ class FilePage extends React.PureComponent {
|
||||
uri: this.state.uri
|
||||
};
|
||||
}
|
||||
|
||||
const prevFileInfo = prevProps.fileInfo;
|
||||
if (!prevFileInfo && fileInfo) {
|
||||
// started downloading
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
// If the media is playable, file/view will be done in onPlaybackStarted
|
||||
if (!isPlayable && !this.state.fileViewLogged) {
|
||||
this.logFileView(uri, fileInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fetchFileInfo(props) {
|
||||
@@ -147,7 +225,7 @@ class FilePage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onDeletePressed = () => {
|
||||
const { deleteFile, fileInfo } = this.props;
|
||||
const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props;
|
||||
|
||||
Alert.alert(
|
||||
'Delete file',
|
||||
@@ -155,7 +233,12 @@ class FilePage extends React.PureComponent {
|
||||
[
|
||||
{ text: 'No' },
|
||||
{ text: 'Yes', onPress: () => {
|
||||
deleteFile(fileInfo.outpoint, true);
|
||||
const { uri } = navigation.state.params;
|
||||
deleteFile(`${claim.txid}:${claim.nout}`, true);
|
||||
deletePurchasedUri(uri);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.deleteDownload(uri);
|
||||
}
|
||||
this.setState({
|
||||
downloadPressed: false,
|
||||
fileViewLogged: false,
|
||||
@@ -169,7 +252,7 @@ class FilePage extends React.PureComponent {
|
||||
}
|
||||
|
||||
onStopDownloadPressed = () => {
|
||||
const { fileInfo, navigation, notify, stopDownload } = this.props;
|
||||
const { deletePurchasedUri, fileInfo, navigation, notify, stopDownload } = this.props;
|
||||
|
||||
Alert.alert(
|
||||
'Stop download',
|
||||
@@ -177,7 +260,12 @@ class FilePage extends React.PureComponent {
|
||||
[
|
||||
{ text: 'No' },
|
||||
{ text: 'Yes', onPress: () => {
|
||||
stopDownload(navigation.state.params.uri, fileInfo);
|
||||
const { uri } = navigation.state.params;
|
||||
stopDownload(uri, fileInfo);
|
||||
deletePurchasedUri(uri);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.deleteDownload(uri);
|
||||
}
|
||||
this.setState({
|
||||
downloadPressed: false,
|
||||
fileViewLogged: false,
|
||||
@@ -189,7 +277,6 @@ class FilePage extends React.PureComponent {
|
||||
// after the file_set_status and file_delete operations, so let the user know
|
||||
notify({
|
||||
message: 'The download will stop momentarily. You do not need to wait to discover something else.',
|
||||
displayType: ['toast']
|
||||
});
|
||||
}}
|
||||
],
|
||||
@@ -207,10 +294,35 @@ class FilePage extends React.PureComponent {
|
||||
utility.keepAwakeOff();
|
||||
utility.showNavigationBar();
|
||||
}
|
||||
if (this.didFocusListener) {
|
||||
this.didFocusListener.remove();
|
||||
}
|
||||
if (window.currentMediaInfo) {
|
||||
window.currentMediaInfo = null;
|
||||
}
|
||||
window.player = null;
|
||||
|
||||
DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted);
|
||||
DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated);
|
||||
DeviceEventEmitter.removeListener('onDownloadCompleted', this.handleDownloadCompleted);
|
||||
}
|
||||
|
||||
handleDownloadStarted = (evt) => {
|
||||
const { startDownload } = this.props;
|
||||
const { uri, outpoint, fileInfo } = evt;
|
||||
startDownload(uri, outpoint, fileInfo);
|
||||
}
|
||||
|
||||
handleDownloadUpdated = (evt) => {
|
||||
const { updateDownload } = this.props;
|
||||
const { uri, outpoint, fileInfo, progress } = evt;
|
||||
updateDownload(uri, outpoint, fileInfo, progress);
|
||||
}
|
||||
|
||||
handleDownloadCompleted = (evt) => {
|
||||
const { completeDownload } = this.props;
|
||||
const { uri, outpoint, fileInfo } = evt;
|
||||
completeDownload(uri, outpoint, fileInfo);
|
||||
}
|
||||
|
||||
localUriForFileInfo = (fileInfo) => {
|
||||
@@ -220,6 +332,32 @@ class FilePage extends React.PureComponent {
|
||||
return 'file:///' + fileInfo.download_path;
|
||||
}
|
||||
|
||||
playerUriForFileInfo = (fileInfo) => {
|
||||
const { streamingUrl } = this.props;
|
||||
if (fileInfo && fileInfo.download_path) {
|
||||
return this.getEncodedDownloadPath(fileInfo);
|
||||
}
|
||||
if (streamingUrl) {
|
||||
return streamingUrl;
|
||||
}
|
||||
if (this.state.currentStreamUrl) {
|
||||
return this.state.currentStreamUrl;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getEncodedDownloadPath = (fileInfo) => {
|
||||
if (this.state.encodedFilePath) {
|
||||
return this.state.encodedFilePath;
|
||||
}
|
||||
|
||||
const { file_name: fileName } = fileInfo;
|
||||
const encodedFileName = encodeURIComponent(fileName).replace(/!/g, '%21');
|
||||
const encodedFilePath = fileInfo.download_path.replace(fileName, encodedFileName);
|
||||
return encodedFilePath;
|
||||
}
|
||||
|
||||
linkify = (text) => {
|
||||
let linkifiedContent = [];
|
||||
let lines = text.split(/\n/g);
|
||||
@@ -284,20 +422,37 @@ class FilePage extends React.PureComponent {
|
||||
this.startTime = null;
|
||||
}
|
||||
|
||||
const { fileInfo, navigation } = this.props;
|
||||
const { claim, navigation } = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
this.logFileView(uri, fileInfo, timeToStartMillis);
|
||||
this.logFileView(uri, claim, timeToStartMillis);
|
||||
|
||||
let payload = { 'Uri': uri };
|
||||
let payload = { 'uri': uri };
|
||||
if (!isNaN(timeToStart)) {
|
||||
payload['Time to Start (seconds)'] = timeToStart;
|
||||
payload['Time to Start (ms)'] = timeToStartMillis;
|
||||
payload['time_to_start_seconds'] = timeToStart;
|
||||
payload['time_to_start_ms'] = timeToStartMillis;
|
||||
}
|
||||
NativeModules.Mixpanel.track('Play', payload);
|
||||
NativeModules.Firebase.track('play', payload);
|
||||
}
|
||||
|
||||
logFileView = (uri, fileInfo, timeToStart) => {
|
||||
const { outpoint, claim_id: claimId } = fileInfo;
|
||||
onPlaybackFinished = () => {
|
||||
if (this.scrollView && this.state.relatedContentY) {
|
||||
this.scrollView.scrollTo({ x: 0, y: this.state.relatedContentY, animated: true});
|
||||
}
|
||||
}
|
||||
|
||||
setRelatedContentPosition = (evt) => {
|
||||
if (!this.state.relatedContentY) {
|
||||
this.setState({ relatedContentY: evt.nativeEvent.layout.y });
|
||||
}
|
||||
}
|
||||
|
||||
logFileView = (uri, claim, timeToStart) => {
|
||||
if (!claim) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { nout, claim_id: claimId, txid } = claim;
|
||||
const outpoint = `${txid}:${nout}`;
|
||||
const params = {
|
||||
uri,
|
||||
outpoint,
|
||||
@@ -311,9 +466,45 @@ class FilePage extends React.PureComponent {
|
||||
this.setState({ fileViewLogged: true });
|
||||
}
|
||||
|
||||
handleSendTip = () => {
|
||||
const { claim, balance, navigation, notify, sendTip } = this.props;
|
||||
const { uri } = navigation.state.params;
|
||||
const { tipAmount } = this.state;
|
||||
|
||||
if (tipAmount > balance) {
|
||||
notify({
|
||||
message: 'Insufficient credits',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
sendTip(tipAmount, claim.claim_id, uri, () => { this.setState({ tipAmount: 0, showTipView: false }) });
|
||||
}
|
||||
|
||||
renderTags = (tags) => {
|
||||
return tags.map((tag, i) => (
|
||||
<Text style={filePageStyle.tagItem} key={`${tag}-${i}`}>{tag}</Text>
|
||||
));
|
||||
}
|
||||
|
||||
onFileDownloadButtonPlayed = () => {
|
||||
const { setPlayerVisible } = this.props;
|
||||
this.startTime = Date.now();
|
||||
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false });
|
||||
setPlayerVisible();
|
||||
}
|
||||
|
||||
onBackButtonPressed = () => {
|
||||
const { navigation, drawerStack, popDrawerStack } = this.props;
|
||||
navigateBack(navigation, drawerStack, popDrawerStack);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
balance,
|
||||
claim,
|
||||
channelUri,
|
||||
costInfo,
|
||||
fileInfo,
|
||||
metadata,
|
||||
contentType,
|
||||
@@ -321,7 +512,11 @@ class FilePage extends React.PureComponent {
|
||||
rewardedContentClaimIds,
|
||||
isResolvingUri,
|
||||
blackListedOutpoints,
|
||||
navigation
|
||||
navigation,
|
||||
position,
|
||||
purchaseUri,
|
||||
thumbnail,
|
||||
title
|
||||
} = this.props;
|
||||
const { uri, autoplay } = navigation.state.params;
|
||||
|
||||
@@ -366,58 +561,83 @@ class FilePage extends React.PureComponent {
|
||||
<Text style={filePageStyle.dmcaText}>
|
||||
In response to a complaint we received under the US Digital Millennium Copyright Act, we have blocked access to this content from our applications.
|
||||
</Text>
|
||||
<Link style={filePageStyle.dmcaLink} href="https://lbry.io/faq/dmca" text="Read More" />
|
||||
<Link style={filePageStyle.dmcaLink} href="https://lbry.com/faq/dmca" text="Read More" />
|
||||
</View>
|
||||
<UriBar value={uri} navigation={navigation} />
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
|
||||
let tags = [];
|
||||
if (claim && claim.value && claim.value.tags) {
|
||||
tags = claim.value.tags;
|
||||
}
|
||||
|
||||
const completed = fileInfo && fileInfo.completed;
|
||||
const title = metadata.title;
|
||||
const isRewardContent = rewardedContentClaimIds.includes(claim.claim_id);
|
||||
const description = metadata.description ? metadata.description : null;
|
||||
const mediaType = Lbry.getMediaType(contentType);
|
||||
const isPlayable = mediaType === 'video' || mediaType === 'audio';
|
||||
const { height, channel_name: channelName, value } = claim;
|
||||
const showActions = !this.state.fullscreenMode &&
|
||||
!this.state.showImageViewer &&
|
||||
!this.state.showWebView &&
|
||||
const showActions = !this.state.streamingMode && !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView;
|
||||
const showFileActions = (fileInfo && fileInfo.download_path) &&
|
||||
(completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes));
|
||||
const channelClaimId =
|
||||
value && value.publisherSignature && value.publisherSignature.certificateId;
|
||||
const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id;
|
||||
const canSendTip = this.state.tipAmount > 0;
|
||||
const fullChannelUri = channelClaimId && channelClaimId.trim().length > 0 ? `${channelName}#${channelClaimId}` : channelName;
|
||||
|
||||
const playerStyle = [filePageStyle.player,
|
||||
this.state.isLandscape ? filePageStyle.containedPlayerLandscape :
|
||||
(this.state.fullscreenMode ? filePageStyle.fullscreenPlayer : filePageStyle.containedPlayer)];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, this.state.fullscreenMode ?
|
||||
filePageStyle.fullscreenPlayerBackground : filePageStyle.containedPlayerBackground];
|
||||
const playerBgStyle = [filePageStyle.playerBackground, filePageStyle.containedPlayerBackground];
|
||||
const fsPlayerBgStyle = [filePageStyle.playerBackground, filePageStyle.fullscreenPlayerBackground];
|
||||
// at least 2MB (or the full download) before media can be loaded
|
||||
const canLoadMedia = fileInfo &&
|
||||
(fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes == fileInfo.total_bytes); // 2MB = 1024*1024*2
|
||||
const canOpen = (mediaType === 'image' || mediaType === 'text') && completed;
|
||||
const canLoadMedia = (this.state.streamingMode) || (fileInfo &&
|
||||
(fileInfo.written_bytes >= 2097152 || fileInfo.written_bytes == fileInfo.total_bytes)); // 2MB = 1024*1024*2
|
||||
const isViewable = (mediaType === 'image' || mediaType === 'text');
|
||||
const isWebViewable = mediaType === 'text';
|
||||
const canOpen = isViewable && completed;
|
||||
const localFileUri = this.localUriForFileInfo(fileInfo);
|
||||
|
||||
const openFile = () => {
|
||||
if (mediaType === 'image') {
|
||||
// use image viewer
|
||||
this.setState({
|
||||
imageUrls: [{
|
||||
url: localFileUri
|
||||
}],
|
||||
showImageViewer: true
|
||||
});
|
||||
if (!this.state.showImageViewer) {
|
||||
this.setState({
|
||||
imageUrls: [{
|
||||
url: localFileUri
|
||||
}],
|
||||
showImageViewer: true
|
||||
});
|
||||
}
|
||||
}
|
||||
if (isWebViewable) {
|
||||
// show webview
|
||||
this.setState({
|
||||
showWebView: true
|
||||
});
|
||||
if (!this.state.showWebView) {
|
||||
this.setState({
|
||||
showWebView: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fileInfo && !this.state.autoDownloadStarted && this.state.uriVars && 'true' === this.state.uriVars.download) {
|
||||
this.setState({ autoDownloadStarted: true }, () => {
|
||||
purchaseUri(uri, costInfo, !isPlayable);
|
||||
if (NativeModules.UtilityModule) {
|
||||
NativeModules.UtilityModule.checkDownloads();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.state.downloadPressed && canOpen) {
|
||||
// automatically open a web viewable or image file after the download button is pressed
|
||||
openFile();
|
||||
}
|
||||
|
||||
innerContent = (
|
||||
<View style={filePageStyle.pageContainer}>
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{this.state.showWebView && isWebViewable && <WebView source={{ uri: localFileUri }}
|
||||
style={filePageStyle.viewer} />}
|
||||
|
||||
@@ -430,88 +650,168 @@ class FilePage extends React.PureComponent {
|
||||
onLayout={this.checkOrientation}>
|
||||
<View style={filePageStyle.mediaContainer}>
|
||||
{((canOpen || (!fileInfo || (isPlayable && !canLoadMedia))) || (!canOpen && fileInfo)) &&
|
||||
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={metadata.thumbnail} />}
|
||||
<FileItemMedia style={filePageStyle.thumbnail} title={title} thumbnail={thumbnail} />}
|
||||
{((!this.state.downloadButtonShown || this.state.downloadPressed) && !this.state.mediaLoaded) &&
|
||||
<ActivityIndicator size="large" color={Colors.LbryGreen} style={filePageStyle.loading} />}
|
||||
{((isPlayable && !completed && !canLoadMedia) || !completed || canOpen) && (!this.state.downloadPressed) &&
|
||||
{((isPlayable && !completed && !canLoadMedia) || canOpen || (!completed && !this.state.streamingMode)) &&
|
||||
(!this.state.downloadPressed) &&
|
||||
<FileDownloadButton uri={uri}
|
||||
style={filePageStyle.downloadButton}
|
||||
openFile={openFile}
|
||||
isPlayable={isPlayable}
|
||||
onPlay={() => {
|
||||
this.startTime = Date.now();
|
||||
this.setState({ downloadPressed: true, autoPlayMedia: true, stopDownloadConfirmed: false });
|
||||
}}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })}
|
||||
onStartDownloadFailed={() => {
|
||||
this.startTime = null;
|
||||
setTimeout(() => {
|
||||
this.setState({ downloadPressed: false, fileViewLogged: false, mediaLoaded: false });
|
||||
}, 500);
|
||||
}} />}
|
||||
isViewable={isViewable}
|
||||
onPlay={this.onFileDownloadButtonPlayed}
|
||||
onView={() => this.setState({ downloadPressed: true })}
|
||||
onButtonLayout={() => this.setState({ downloadButtonShown: true })} />}
|
||||
{!fileInfo && <FilePrice uri={uri} style={filePageStyle.filePriceContainer} textStyle={filePageStyle.filePriceText} />}
|
||||
</View>
|
||||
{canLoadMedia && fileInfo && <View style={playerBgStyle}
|
||||
ref={(ref) => { this.playerBackground = ref; }}
|
||||
onLayout={(evt) => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}} />}
|
||||
{canLoadMedia && fileInfo && <MediaPlayer
|
||||
fileInfo={fileInfo}
|
||||
assignPlayer={(ref) => { this.player = ref; }}
|
||||
uri={uri}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={(evt) => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
/>}
|
||||
|
||||
{fileInfo && showActions &&
|
||||
<TouchableOpacity style={filePageStyle.backButton} onPress={this.onBackButtonPressed}>
|
||||
<Icon name={"arrow-left"} size={18} style={filePageStyle.backButtonIcon} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
|
||||
<View style={playerBgStyle}
|
||||
ref={(ref) => { this.playerBackground = ref; }}
|
||||
onLayout={(evt) => {
|
||||
if (!this.state.playerBgHeight) {
|
||||
this.setState({ playerBgHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}} />}
|
||||
{((this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) && this.state.fullscreenMode) &&
|
||||
<View style={fsPlayerBgStyle} />}
|
||||
{(this.state.streamingMode || (canLoadMedia && fileInfo && isPlayable)) &&
|
||||
<MediaPlayer
|
||||
claim={claim}
|
||||
assignPlayer={(ref) => { this.player = ref; }}
|
||||
uri={uri}
|
||||
source={this.playerUriForFileInfo(fileInfo)}
|
||||
style={playerStyle}
|
||||
autoPlay={autoplay || this.state.autoPlayMedia}
|
||||
onFullscreenToggled={this.handleFullscreenToggle}
|
||||
onLayout={(evt) => {
|
||||
if (!this.state.playerHeight) {
|
||||
this.setState({ playerHeight: evt.nativeEvent.layout.height });
|
||||
}
|
||||
}}
|
||||
onMediaLoaded={() => this.onMediaLoaded(channelName, title, uri)}
|
||||
onBackButtonPressed={this.onBackButtonPressed}
|
||||
onPlaybackStarted={this.onPlaybackStarted}
|
||||
onPlaybackFinished={this.onPlaybackFinished}
|
||||
thumbnail={thumbnail}
|
||||
position={position}
|
||||
/>}
|
||||
|
||||
{(showActions && showFileActions) &&
|
||||
<View style={filePageStyle.actions}>
|
||||
{completed && <Button style={filePageStyle.actionButton}
|
||||
theme={"light"}
|
||||
icon={"trash"}
|
||||
text={"Delete"}
|
||||
onPress={this.onDeletePressed} />}
|
||||
{!completed && fileInfo && !fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed &&
|
||||
<Button style={filePageStyle.actionButton}
|
||||
theme={"light"}
|
||||
text={"Stop Download"}
|
||||
onPress={this.onStopDownloadPressed} />
|
||||
}
|
||||
{showFileActions &&
|
||||
<View style={filePageStyle.fileActions}>
|
||||
{completed && <Button style={filePageStyle.actionButton}
|
||||
theme={"light"}
|
||||
icon={"trash"}
|
||||
text={"Delete"}
|
||||
onPress={this.onDeletePressed} />}
|
||||
{!completed && fileInfo && !fileInfo.stopped &&
|
||||
fileInfo.written_bytes < fileInfo.total_bytes &&
|
||||
!this.state.stopDownloadConfirmed &&
|
||||
<Button style={filePageStyle.actionButton}
|
||||
icon={"stop"}
|
||||
theme={"light"}
|
||||
text={"Stop Download"}
|
||||
onPress={this.onStopDownloadPressed} />
|
||||
}
|
||||
</View>}
|
||||
</View>}
|
||||
<ScrollView
|
||||
style={showActions ? filePageStyle.scrollContainerActions : filePageStyle.scrollContainer}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}>
|
||||
<Text style={filePageStyle.title} selectable={true}>{title}</Text>
|
||||
{channelName && <Link style={filePageStyle.channelName}
|
||||
selectable={true}
|
||||
text={channelName}
|
||||
onPress={() => {
|
||||
const channelUri = normalizeURI(channelName);
|
||||
navigateToUri(navigation, channelUri);
|
||||
}} />}
|
||||
contentContainerstyle={showActions ? null : filePageStyle.scrollContent}
|
||||
keyboardShouldPersistTaps={'handled'}
|
||||
ref={(ref) => { this.scrollView = ref; }}>
|
||||
<TouchableWithoutFeedback style={filePageStyle.titleTouch}
|
||||
onPress={() => this.setState({ showDescription: !this.state.showDescription })}>
|
||||
<View style={filePageStyle.titleRow}>
|
||||
<Text style={filePageStyle.title} selectable={true}>{title}</Text>
|
||||
<View style={filePageStyle.descriptionToggle}>
|
||||
<Icon name={this.state.showDescription ? "caret-up" : "caret-down"} size={24} />
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
{channelName &&
|
||||
<View style={filePageStyle.channelRow}>
|
||||
<View style={filePageStyle.publishInfo}>
|
||||
<Link style={filePageStyle.channelName}
|
||||
selectable={true}
|
||||
text={channelName}
|
||||
numberOfLines={1}
|
||||
ellipsizeMode={"tail"}
|
||||
onPress={() => {
|
||||
navigateToUri(navigation, normalizeURI(fullChannelUri));
|
||||
}} />
|
||||
<DateTime
|
||||
style={filePageStyle.publishDate}
|
||||
textStyle={filePageStyle.publishDateText}
|
||||
uri={uri}
|
||||
formatOptions={{ day: 'numeric', month: 'long', year: 'numeric' }}
|
||||
show={DateTime.SHOW_DATE} />
|
||||
</View>
|
||||
<View style={filePageStyle.subscriptionRow}>
|
||||
<Button style={[filePageStyle.actionButton, filePageStyle.tipButton]}
|
||||
theme={"light"}
|
||||
icon={"gift"}
|
||||
onPress={() => this.setState({ showTipView: true })} />
|
||||
<SubscribeButton
|
||||
style={filePageStyle.actionButton}
|
||||
uri={fullChannelUri}
|
||||
name={channelName} />
|
||||
<SubscribeNotificationButton
|
||||
style={[filePageStyle.actionButton, filePageStyle.bellButton]}
|
||||
uri={fullChannelUri}
|
||||
name={channelName} />
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
|
||||
{description && description.length > 0 && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView && <View style={filePageStyle.divider} />}
|
||||
{this.state.showTipView &&
|
||||
<View style={filePageStyle.tipCard}>
|
||||
<View style={filePageStyle.row}>
|
||||
<View style={filePageStyle.amountRow}>
|
||||
<TextInput ref={ref => this.tipAmountInput = ref}
|
||||
onChangeText={value => this.setState({tipAmount: value})}
|
||||
keyboardType={'numeric'}
|
||||
placeholder={'0'}
|
||||
value={this.state.tipAmount}
|
||||
style={[filePageStyle.input, filePageStyle.tipAmountInput]} />
|
||||
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
|
||||
</View>
|
||||
<Link style={[filePageStyle.link, filePageStyle.cancelTipLink]} text={'Cancel'} onPress={() => this.setState({ showTipView: false })} />
|
||||
<Button text={'Send a tip'}
|
||||
style={[filePageStyle.button, filePageStyle.sendButton]}
|
||||
disabled={!canSendTip}
|
||||
onPress={this.handleSendTip} />
|
||||
</View>
|
||||
</View>}
|
||||
|
||||
{description && <Text style={filePageStyle.description} selectable={true}>{this.linkify(description)}</Text>}
|
||||
{(this.state.showDescription && description && description.length > 0) && <View style={filePageStyle.divider} />}
|
||||
{(this.state.showDescription && description) && (
|
||||
<View>
|
||||
<Text style={filePageStyle.description} selectable={true}>{this.linkify(description)}</Text>
|
||||
{tags && tags.length > 0 && (
|
||||
<View style={filePageStyle.tagContainer}>
|
||||
<Text style={filePageStyle.tagTitle}>Tags</Text>
|
||||
<View style={filePageStyle.tagList}>{this.renderTags(tags)}</View>
|
||||
</View>
|
||||
)}
|
||||
</View>)}
|
||||
|
||||
{(costInfo && parseFloat(costInfo.cost) > balance) && <FileRewardsDriver navigation={navigation} />}
|
||||
|
||||
<View onLayout={this.setRelatedContentPosition} />
|
||||
<RelatedContent navigation={navigation} uri={uri} />
|
||||
</ScrollView>
|
||||
</View>
|
||||
)}
|
||||
{!this.state.fullscreenMode && <FloatingWalletBalance navigation={navigation} />}
|
||||
{!this.state.fullscreenMode && <UriBar value={uri} navigation={navigation} />}
|
||||
{(!this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView) &&
|
||||
<FloatingWalletBalance navigation={navigation} />}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
import { connect } from 'react-redux';
|
||||
import { doNotify } from 'lbry-redux';
|
||||
import { doToast } from 'lbry-redux';
|
||||
import {
|
||||
doGenerateAuthToken,
|
||||
doAuthenticate,
|
||||
doCheckSync,
|
||||
doGetSync,
|
||||
doSetDefaultAccount,
|
||||
doSyncApply,
|
||||
doUserEmailNew,
|
||||
doUserResendVerificationEmail,
|
||||
selectAuthToken,
|
||||
selectEmailNewErrorMessage,
|
||||
selectEmailNewIsPending,
|
||||
selectEmailToVerify,
|
||||
selectIsAuthenticating
|
||||
selectAuthenticationIsPending,
|
||||
selectHasSyncedWallet,
|
||||
selectGetSyncIsPending,
|
||||
selectSyncApplyIsPending,
|
||||
selectSyncApplyErrorMessage,
|
||||
selectSyncData,
|
||||
selectSyncHash,
|
||||
selectUser,
|
||||
} from 'lbryinc';
|
||||
import { doSetClientSetting } from 'redux/actions/settings';
|
||||
import FirstRun from './view';
|
||||
|
||||
const select = (state) => ({
|
||||
authenticating: selectIsAuthenticating(state),
|
||||
authenticating: selectAuthenticationIsPending(state),
|
||||
authToken: selectAuthToken(state),
|
||||
emailToVerify: selectEmailToVerify(state),
|
||||
emailNewErrorMessage: selectEmailNewErrorMessage(state),
|
||||
emailNewPending: selectEmailNewIsPending(state),
|
||||
hasSyncedWallet: selectHasSyncedWallet(state),
|
||||
getSyncIsPending: selectGetSyncIsPending(state),
|
||||
syncApplyErrorMessage: selectSyncApplyErrorMessage(state),
|
||||
syncApplyIsPending: selectSyncApplyIsPending(state),
|
||||
syncHash: selectSyncHash(state),
|
||||
syncData: selectSyncData(state),
|
||||
user: selectUser(state),
|
||||
});
|
||||
|
||||
const perform = dispatch => ({
|
||||
addUserEmail: email => dispatch(doUserEmailNew(email)),
|
||||
generateAuthToken: installationId => dispatch(doGenerateAuthToken(installationId)),
|
||||
notify: data => dispatch(doNotify(data))
|
||||
authenticate: (appVersion, os) => dispatch(doAuthenticate(appVersion, os)),
|
||||
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
|
||||
syncApply: (hash, data, password) => dispatch(doSyncApply(hash, data, password)),
|
||||
getSync: password => dispatch(doGetSync(password)),
|
||||
checkSync: () => dispatch(doCheckSync()),
|
||||
setDefaultAccount: () => dispatch(doSetDefaultAccount()),
|
||||
notify: data => dispatch(doToast(data)),
|
||||
resendVerificationEmail: email => dispatch(doUserResendVerificationEmail(email))
|
||||
});
|
||||
|
||||
export default connect(select, perform)(FirstRun);
|
||||
export default connect(select, perform)(FirstRun);
|
||||
@@ -1,65 +1,37 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Linking,
|
||||
NativeModules,
|
||||
Platform,
|
||||
Text,
|
||||
TextInput,
|
||||
View
|
||||
} from 'react-native';
|
||||
import Colors from '../../../styles/colors';
|
||||
import Constants from '../../../constants';
|
||||
import firstRunStyle from '../../../styles/firstRun';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
|
||||
class EmailCollectPage extends React.PureComponent {
|
||||
static MAX_STATUS_TRIES = 15;
|
||||
|
||||
state = {
|
||||
email: null,
|
||||
authenticationStarted: false,
|
||||
authenticationFailed: false,
|
||||
placeholder: 'you@example.com',
|
||||
statusTries: 0
|
||||
verifying: true
|
||||
};
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const { authenticating, authToken } = this.props;
|
||||
const { showNextPage } = this.props;
|
||||
const { user } = nextProps;
|
||||
|
||||
if (this.state.authenticationStarted && !authenticating && authToken === null) {
|
||||
this.setState({ authenticationFailed: true, authenticationStarted: false });
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// call user/new
|
||||
const { generateAuthToken, authenticating, authToken } = this.props;
|
||||
if (!authToken && !authenticating) {
|
||||
this.startAuthenticating();
|
||||
}
|
||||
|
||||
AsyncStorage.getItem('firstRunEmail').then(email => {
|
||||
if (email) {
|
||||
this.setState({ email });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startAuthenticating = () => {
|
||||
const { generateAuthToken } = this.props;
|
||||
this.setState({ authenticationStarted: true, authenticationFailed: false });
|
||||
Lbry.status().then(info => {
|
||||
generateAuthToken(info.installation_id)
|
||||
}).catch(error => {
|
||||
if (this.state.statusTries >= EmailCollectPage.MAX_STATUS_TRIES) {
|
||||
this.setState({ authenticationFailed: true });
|
||||
if (this.state.verifying) {
|
||||
if (user && user.primary_email && user.has_verified_email) {
|
||||
if (showNextPage) {
|
||||
showNextPage();
|
||||
}
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startAuthenticating();
|
||||
this.setState({ statusTries: this.state.statusTries + 1 });
|
||||
}, 1000); // Retry every second for a maximum of MAX_STATUS_TRIES tries (15 seconds)
|
||||
this.setState({ verifying: false });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleChangeText = (text) => {
|
||||
@@ -70,52 +42,36 @@ class EmailCollectPage extends React.PureComponent {
|
||||
onEmailChanged(text);
|
||||
}
|
||||
AsyncStorage.setItem(Constants.KEY_FIRST_RUN_EMAIL, text);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
|
||||
}
|
||||
|
||||
render() {
|
||||
const { authenticating, authToken, onEmailChanged, onEmailViewLayout, emailToVerify } = this.props;
|
||||
const { onEmailViewLayout } = this.props;
|
||||
|
||||
let content;
|
||||
if (this.state.authenticationFailed) {
|
||||
// Ask the user to try again
|
||||
content = (
|
||||
<View>
|
||||
<Text style={firstRunStyle.paragraph}>The LBRY servers were unreachable at this time. Please check your Internet connection and then restart the app to try again.</Text>
|
||||
</View>
|
||||
);
|
||||
} else if (!authToken || authenticating) {
|
||||
content = (
|
||||
<View>
|
||||
<ActivityIndicator size="large" color={Colors.White} style={firstRunStyle.waiting} />
|
||||
<Text style={firstRunStyle.paragraph}>Please wait while we get some things ready...</Text>
|
||||
</View>
|
||||
);
|
||||
} else {
|
||||
content = (
|
||||
<View onLayout={onEmailViewLayout}>
|
||||
<Text style={firstRunStyle.title}>Rewards.</Text>
|
||||
<Text style={firstRunStyle.paragraph}>You can earn LBRY Credits (LBC) rewards by completing various tasks in the app.</Text>
|
||||
<Text style={firstRunStyle.paragraph}>Please provide a valid email address below to be able to claim your rewards.</Text>
|
||||
<TextInput style={firstRunStyle.emailInput}
|
||||
placeholder={this.state.placeholder}
|
||||
underlineColorAndroid="transparent"
|
||||
value={this.state.email}
|
||||
onChangeText={text => this.handleChangeText(text)}
|
||||
onFocus={() => {
|
||||
if (!this.state.email || this.state.email.length === 0) {
|
||||
this.setState({ placeholder: '' });
|
||||
}
|
||||
}}
|
||||
onBlur={() => {
|
||||
if (!this.state.email || this.state.email.length === 0) {
|
||||
this.setState({ placeholder: 'you@example.com' });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Text style={firstRunStyle.infoParagraph}>This information is disclosed only to LBRY, Inc. and not to the LBRY network. It is only required to earn LBRY rewards and may be used to sync usage data across devices.</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const content = (
|
||||
<View onLayout={onEmailViewLayout}>
|
||||
<Text style={firstRunStyle.title}>Setup account</Text>
|
||||
<TextInput style={firstRunStyle.emailInput}
|
||||
placeholder={this.state.placeholder}
|
||||
underlineColorAndroid="transparent"
|
||||
selectionColor={Colors.NextLbryGreen}
|
||||
value={this.state.email}
|
||||
onChangeText={text => this.handleChangeText(text)}
|
||||
onFocus={() => {
|
||||
if (!this.state.email || this.state.email.length === 0) {
|
||||
this.setState({ placeholder: '' });
|
||||
}
|
||||
}}
|
||||
onBlur={() => {
|
||||
if (!this.state.email || this.state.email.length === 0) {
|
||||
this.setState({ placeholder: 'you@example.com' });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Text style={firstRunStyle.paragraph}>An account will allow you to earn rewards and keep your account and settings synced.</Text>
|
||||
<Text style={firstRunStyle.infoParagraph}>This information is disclosed only to LBRY, Inc. and not to the LBRY network.</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={firstRunStyle.container}>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Linking,
|
||||
NativeModules,
|
||||
Platform,
|
||||
Switch,
|
||||
Text,
|
||||
TextInput,
|
||||
View
|
||||
} from 'react-native';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Button from 'component/button';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
|
||||
class EmailVerifyPage extends React.PureComponent {
|
||||
onResendPressed = () => {
|
||||
const { email, notify, resendVerificationEmail } = this.props;
|
||||
resendVerificationEmail(email);
|
||||
AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
|
||||
notify({ message: 'Please follow the instructions in the email sent to your address to continue.' });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { onEmailViewLayout, email } = this.props;
|
||||
|
||||
const content = (
|
||||
<View onLayout={onEmailViewLayout}>
|
||||
<Text style={firstRunStyle.title}>Verify Email</Text>
|
||||
<Text style={firstRunStyle.paragraph}>An email has been sent to <Text style={firstRunStyle.nowrap} numberOfLines={1}>{email}</Text>. Please follow the instructions in the message to verify your email address.</Text>
|
||||
|
||||
<View style={firstRunStyle.buttonContainer}>
|
||||
<Button style={firstRunStyle.verificationButton} theme={"light"} text={"Resend"} onPress={this.onResendPressed} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={firstRunStyle.container}>
|
||||
{content}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default EmailVerifyPage;
|
||||
@@ -0,0 +1,52 @@
|
||||
import React from 'react';
|
||||
import { Lbry } from 'lbry-redux';
|
||||
import {
|
||||
ActivityIndicator,
|
||||
AsyncStorage,
|
||||
Linking,
|
||||
NativeModules,
|
||||
Platform,
|
||||
Switch,
|
||||
Text,
|
||||
TextInput,
|
||||
View
|
||||
} from 'react-native';
|
||||
import Colors from 'styles/colors';
|
||||
import Constants from 'constants';
|
||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import firstRunStyle from 'styles/firstRun';
|
||||
|
||||
class SkipAccountPage extends React.PureComponent {
|
||||
state = {
|
||||
confirmed: false
|
||||
};
|
||||
|
||||
render() {
|
||||
const { onSkipAccountViewLayout, onSkipSwitchChanged } = this.props;
|
||||
|
||||
const content = (
|
||||
<View onLayout={onSkipAccountViewLayout}>
|
||||
<View style={firstRunStyle.row}>
|
||||
<Icon name="exclamation-triangle" style={firstRunStyle.titleIcon} size={32} color={Colors.White} />
|
||||
<Text style={firstRunStyle.title}>Are you sure?</Text>
|
||||
</View>
|
||||
<Text style={firstRunStyle.paragraph}>Without an account, you will not receive rewards, sync and backup services, or security updates.</Text>
|
||||
|
||||
<View style={[firstRunStyle.row, firstRunStyle.confirmContainer]}>
|
||||
<View style={firstRunStyle.rowSwitch}>
|
||||
<Switch value={this.state.confirmed} onValueChange={value => { this.setState({ confirmed: value }); onSkipSwitchChanged(value); }} />
|
||||
</View>
|
||||
<Text style={firstRunStyle.rowParagraph}>I understand that by uninstalling LBRY I will lose any balances or published content with no recovery option.</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
return (
|
||||
<View style={firstRunStyle.container}>
|
||||
{content}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SkipAccountPage;
|
||||
Loaded 100 of 931 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user