Skip to content

Add windows progress bar #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js
.*/*[.]windows.js

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ buck-out/
\.buckd/
!debug.keystore
*.keystore

#VS code
.vscode/**
69 changes: 65 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
[![MIT License][license-badge]][license]
[![Lean Core Badge][lean-core-badge]][lean-core-issue]

ProgressBar Component for iOS, based on UIProgressView.
ProgressBar Component for iOS (based on UIProgressView) and Windows.

<img src="https://user-images.githubusercontent.com/6936373/73007429-e09dd500-3e4f-11ea-85dd-ce06be668975.png" width="320"/>
| iOS | Windows |
| --- | --- |
| <img src="https://user-images.githubusercontent.com/6936373/73007429-e09dd500-3e4f-11ea-85dd-ce06be668975.png" width="320"> | <img src="https://user-images.githubusercontent.com/42554868/87102503-fb4de580-c206-11ea-98f7-b9f911d115f8.gif" width="320" height="500"> >

## Getting started

Expand Down Expand Up @@ -40,8 +42,31 @@ Run the following commands
react-native link @react-native-community/progress-view
```

#### Windows
##### Add the `progress-view` project to your solution.

1. Open the solution in Visual Studio 2019
2. Right-click Solution icon in Solution Explorer > Add > Existing Project
Select `node_modules\@react-native-community\progress-view\windows\progress-view\progress-view.vcxproj`

##### **windows/myapp.sln**
Add a reference to `progress-view` to your main application project. From Visual Studio 2019:

Right-click main application project > Add > Reference...
Check `progress-view` from Solution Projects.

##### **pch.h**

Add `#include "winrt/progress_view.h"`.

##### **app.cpp**

Add `PackageProviders().Append(winrt::progress_view::ReactPackageProvider());` before `InitializeComponent();`.


### Manual installation

#### IOS
<details>
<summary>Manually linking the library - iOS</summary>

Expand All @@ -54,9 +79,36 @@ react-native link @react-native-community/progress-view

## Usage

Import ProgressView from `@react-native-community/progress-view`

```javascript
import {ProgressView} from "@react-native-community/progress-view";
```
Add ProgressView like this

```jsx
<ProgressView
progressTintColor="orange"
trackTintColor="blue"
progress={0.7}
/>
```

### Running Example App

#### Windows
1. Clone branch
2. cd into progress_view and run `yarn install`
3. run `yarn add react-native@0.62 --dev` (React Native Windows relies on a version of react-native lower than iOS)
4. Start metro server with `yarn start:windows`
5. Open Visual Studios and open `example/windows/ProgressViewExample.sln`
6. Set to Debug x64 and start solution

#### IOS
1. Clone branch
2. cd into progress-view and run `yarn install`
2. cd into example/ios and run `pod install`
4. cd back into progress-view and run `yarn ios`

## Reference

Expand Down Expand Up @@ -109,7 +161,7 @@ The tint color of the progress bar itself.

### `progressViewStyle`

The progress bar style.
The progress bar style. Network images only work on Windows.

| Type | Required |
| ---------------------- | -------- |
Expand All @@ -119,7 +171,7 @@ The progress bar style.

### `trackImage`

A stretchable image to display behind the progress bar.
A stretchable image to display behind the progress bar. Network images only work on Windows.

| Type | Required |
| ---------------------- | -------- |
Expand All @@ -135,6 +187,15 @@ The tint color of the progress bar track.
| ------ | -------- |
| string | No |

### `isIndeterminate`

Turns progress bar into an indeterminate progress bar

| Type | Required | Platform |
| ------ | -------- | -------- |
| bool | No | Windows |


## Contributors

- [Kaiden Sin](https://github.com/kdenz) - [Passionate Product Maker and Coder](http://linkedin.com/in/kaiden)
Expand Down
41 changes: 40 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import {StyleSheet, Text, SafeAreaView} from 'react-native';
import {StyleSheet, Text, SafeAreaView, Platform} from 'react-native';
import {ProgressView} from '../js';

type Props = {||};
Expand Down Expand Up @@ -66,6 +66,40 @@ export class App extends React.Component<Props, State> {
progressTintColor="yellow"
progress={this.getProgress(0.8)}
/>

<Text style={styles.text}>isIndeterminate</Text>
<ProgressView style={styles.progressView} isIndeterminate={true} />
<Text style={styles.text}>ProgressImage with local image</Text>
<ProgressView
style={styles.progressView}
progress={0.5}
progressImage={require('./test.png')}
/>
<Text style={styles.text}>TrackImage with network image</Text>
{Platform.OS === 'windows' ? (
<ProgressView
style={styles.progressView}
progress={0.5}
trackImage={{
uri: 'https://homepages.cae.wisc.edu/~ece533/images/cat.png',
}}
/>
) : (
<Text>Network Images only work on Windows</Text>
)}
<Text style={styles.text}>TrackTint Color</Text>
<ProgressView
style={styles.progressView}
progress={0.8}
trackTintColor={'red'}
progressTintColor={'yellow'}
/>
<Text style={styles.text}>Bar Style</Text>
<ProgressView
style={styles.progressView}
progress={0.4}
progressViewStyle={'bar'}
/>
</SafeAreaView>
);
}
Expand All @@ -83,4 +117,9 @@ const styles = StyleSheet.create({
fontSize: 24,
fontWeight: '700',
},
text: {
fontSize: 18,
fontWeight: '500',
marginTop: 10,
},
});
168 changes: 84 additions & 84 deletions example/android/gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Binary file added example/test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading