Committed by
GitHub
Set up federated plugin (#42)
* Federated setup * Add .github * Revert "Merge branch 'master' into federated-plugin" This reverts commit d78b1423272b1c9bc0549fdd87efb4c3fef0019a. * Init platform interface * Setup wakelock_web * Setup wakelock * Cleanup * Add pigeons * Implement Android * Implement platform interface * Test platform interface * wakelock_platform_interface initial release * Main README * wakelock README * wakelock tests * Integration testing * iOS implementation * Finish wakelock * Implement web * Web tests * comment * Web dependency * Add checks * Fix checks * Relative here * reorder * Skip pub get * Desperation * l * Fix checks * Add pana * Pana relative path * Add tests * Version * disable web checks * Complete actions
Showing
129 changed files
with
3131 additions
and
775 deletions
.github/CONTRIBUTING.md
0 → 100644
| 1 | +# Contributing guide | ||
| 2 | + | ||
| 3 | +## Steps | ||
| 4 | + | ||
| 5 | +The following steps are based on a version of [flutter/plugin's contributing guide](https://github.com/flutter/plugins/blob/2ea66626c245a4373a6e07706ab2e7d471e25bd6/CONTRIBUTING.md). | ||
| 6 | + | ||
| 7 | +### Creating a fork | ||
| 8 | + | ||
| 9 | +- If you have not yet configured your machine with an SSH key that is known to GitHub, then follow [GitHub's directions](https://help.github.com/articles/generating-ssh-keys/) to generate an SSH key. | ||
| 10 | +- Fork [this repository](https://github.com/creativecreatorormaybenot/wakelock) using the "Fork" button in the upper right corner of the repository's GitHub page. | ||
| 11 | +- `git clone git@github.com:<github_user_name>/wakelock.git` | ||
| 12 | +- `cd wakelock` | ||
| 13 | +- `git remote add upstream git@github.com:creativecreatorormaybenot/wakelock.git` | ||
| 14 | + This ensures that `git fetch upstream` is possible to fetch from this remote repository instead of from your own fork to get the latest changes. | ||
| 15 | + | ||
| 16 | +### Create pull requests | ||
| 17 | + | ||
| 18 | +- Fetch the latest repo state: `git fetch upstream` | ||
| 19 | +- Create a feature branch: `git checkout upstream/master -b <name_of_your_branch>` | ||
| 20 | +- Now, you can change the code necessary for your patch. | ||
| 21 | + | ||
| 22 | + Make sure that you bump the version in [`pubspec.yaml`][pubspec]. You **must** bump the Pubspec | ||
| 23 | + version when a new package version should be released and edit the `CHANGELOG.md` of the package | ||
| 24 | + accordingly. | ||
| 25 | + The version format needs to follow [Dart's semantic versioning][dart semver]. You need to take | ||
| 26 | + [caret syntax][] into consideration when landing breaking changes. | ||
| 27 | + | ||
| 28 | +- Commit your changes: `git commit -am "<commit_message>"` | ||
| 29 | +- Push your changes: `git push origin <name_of_your_branch>` | ||
| 30 | + | ||
| 31 | +After having followed these steps, you are ready to [create a pull request](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork). | ||
| 32 | +The GitHub interface makes this very easy by providing a button on your fork page that creates a pull request with changes from a recently pushed to branch. | ||
| 33 | +Alternatively, you can also use `git pull-request` via [GitHub hub](https://hub.github.com/). | ||
| 34 | + | ||
| 35 | +### Notes | ||
| 36 | + | ||
| 37 | +- You should remember to exclude all files and directories your IDE might generate using the `.gitignore` files (if they do not already contain them for your IDE). | ||
| 38 | + If you feel like you can make useful additions to any of the `.gitignore` files, you can include them in your pull request, potentially with an explanation. | ||
| 39 | + | ||
| 40 | +- It is probably easier for you to run the integration tests for the plugin locally using `flutter drive --target=test_driver/app.dart` in the `example` directory | ||
| 41 | + before opening a pull request (CI also runs the integration tests). | ||
| 42 | + This way you can ensure that any changes you have made work properly. Furthermore, you might also want to add some tests if you implement new functionality. | ||
| 43 | + | ||
| 44 | +- You should also run `dart format .` in the root directory and make sure that `flutter analyze` does not report any errors. | ||
| 45 | + | ||
| 46 | +[dart semver]: https://dart.dev/tools/pub/versioning#semantic-versions | ||
| 47 | +[caret syntax]: https://dart.dev/tools/pub/dependencies#caret-syntax |
.github/PULL_REQUEST_TEMPLATE.md
0 → 100644
| @@ -11,11 +11,14 @@ on: | @@ -11,11 +11,14 @@ on: | ||
| 11 | - '**/pubspec.yaml' | 11 | - '**/pubspec.yaml' |
| 12 | - '**/test/**' | 12 | - '**/test/**' |
| 13 | - '**/test_driver/**' | 13 | - '**/test_driver/**' |
| 14 | + - '**/assets/**' | ||
| 15 | + - '**/integration_test/**' | ||
| 14 | 16 | ||
| 15 | jobs: | 17 | jobs: |
| 16 | analyze: | 18 | analyze: |
| 19 | + timeout-minutes: 7 | ||
| 17 | runs-on: ${{ matrix.os }} | 20 | runs-on: ${{ matrix.os }} |
| 18 | - name: Format check & analysis (${{ matrix.channel }} on ${{ matrix.os }}) | 21 | + name: Analysis of ${{ matrix.package }} (${{ matrix.channel }}; ${{ matrix.os }}) |
| 19 | strategy: | 22 | strategy: |
| 20 | matrix: | 23 | matrix: |
| 21 | os: | 24 | os: |
| @@ -24,6 +27,10 @@ jobs: | @@ -24,6 +27,10 @@ jobs: | ||
| 24 | - 'stable' | 27 | - 'stable' |
| 25 | - 'beta' | 28 | - 'beta' |
| 26 | - 'dev' | 29 | - 'dev' |
| 30 | + package: | ||
| 31 | + - 'wakelock' | ||
| 32 | + - 'wakelock_platform_interface' | ||
| 33 | + - 'wakelock_web' | ||
| 27 | fail-fast: false | 34 | fail-fast: false |
| 28 | 35 | ||
| 29 | steps: | 36 | steps: |
| @@ -31,37 +38,36 @@ jobs: | @@ -31,37 +38,36 @@ jobs: | ||
| 31 | - uses: subosito/flutter-action@v1.3.2 | 38 | - uses: subosito/flutter-action@v1.3.2 |
| 32 | with: | 39 | with: |
| 33 | channel: ${{ matrix.channel }} | 40 | channel: ${{ matrix.channel }} |
| 34 | - - name: Setup projects (root & example) | ||
| 35 | - run: | | ||
| 36 | - flutter pub get | ||
| 37 | - cd example | ||
| 38 | - flutter create . | ||
| 39 | - rm -rf test | ||
| 40 | - flutter pub get | ||
| 41 | - cd .. | 41 | + - run: flutter pub get |
| 42 | + working-directory: ${{ matrix.package }} | ||
| 42 | - name: Check format | 43 | - name: Check format |
| 43 | - run: flutter format . --set-exit-if-changed --fix | 44 | + working-directory: ${{ matrix.package }} |
| 45 | + run: dart format . --set-exit-if-changed | ||
| 44 | - run: flutter analyze | 46 | - run: flutter analyze |
| 47 | + working-directory: ${{ matrix.package }} | ||
| 45 | 48 | ||
| 46 | test: | 49 | test: |
| 47 | - # Not using the conditional as jobs are not re-run when the draft status changes. | ||
| 48 | - #if: github.event.pull_request.draft == false | 50 | + timeout-minutes: 14 |
| 49 | runs-on: macos-latest | 51 | runs-on: macos-latest |
| 50 | - name: Unit & integration tests (${{ matrix.channel }} on ${{ matrix.device }}) | 52 | + name: Testing of ${{ matrix.package }} (${{ matrix.channel }}; ${{ matrix.device }}) |
| 51 | strategy: | 53 | strategy: |
| 52 | matrix: | 54 | matrix: |
| 53 | device: | 55 | device: |
| 54 | - 'iPhone 11 Pro Max (13.7)' | 56 | - 'iPhone 11 Pro Max (13.7)' |
| 55 | - - 'Android' | ||
| 56 | channel: | 57 | channel: |
| 57 | - 'stable' | 58 | - 'stable' |
| 58 | - 'beta' | 59 | - 'beta' |
| 59 | - 'dev' | 60 | - 'dev' |
| 61 | + package: | ||
| 62 | + - 'wakelock' | ||
| 63 | + - 'wakelock_platform_interface' | ||
| 64 | + # Web tests do not work for now. | ||
| 65 | + # - 'wakelock_web' | ||
| 60 | fail-fast: false | 66 | fail-fast: false |
| 61 | 67 | ||
| 62 | steps: | 68 | steps: |
| 63 | - name: Start iOS simulator | 69 | - name: Start iOS simulator |
| 64 | - if: contains(matrix.device, 'iPhone') | 70 | + if: matrix.package == 'wakelock' |
| 65 | run: | | 71 | run: | |
| 66 | xcrun instruments -s | 72 | xcrun instruments -s |
| 67 | UDID=$( | 73 | UDID=$( |
| @@ -76,25 +82,18 @@ jobs: | @@ -76,25 +82,18 @@ jobs: | ||
| 76 | - uses: subosito/flutter-action@v1.3.2 | 82 | - uses: subosito/flutter-action@v1.3.2 |
| 77 | with: | 83 | with: |
| 78 | channel: ${{ matrix.channel }} | 84 | channel: ${{ matrix.channel }} |
| 79 | - - name: Setup projects (root & example) | ||
| 80 | - run: | | ||
| 81 | - flutter pub get | ||
| 82 | - cd example | ||
| 83 | - flutter create . | ||
| 84 | - rm -rf test | ||
| 85 | - flutter pub get | ||
| 86 | - cd .. | ||
| 87 | - - name: Run unit tests | 85 | + - run: flutter pub get |
| 86 | + working-directory: ${{ matrix.package }} | ||
| 87 | + - name: Run unit tests (tester) | ||
| 88 | + if: matrix.package != 'wakelock_web' | ||
| 88 | run: flutter test | 89 | run: flutter test |
| 89 | - - name: Run integration tests on iOS | ||
| 90 | - if: contains(matrix.device, 'iPhone') | 90 | + working-directory: ${{ matrix.package }} |
| 91 | + - name: Run unit tests (chrome) | ||
| 92 | + if: matrix.package == 'wakelock_web' | ||
| 93 | + run: flutter test --platform chrome | ||
| 94 | + working-directory: ${{ matrix.package }} | ||
| 95 | + - name: Integration tests on iOS | ||
| 96 | + if: matrix.package == 'wakelock' | ||
| 91 | run: | | 97 | run: | |
| 92 | - cd example | ||
| 93 | - flutter drive --target=test_driver/app.dart | ||
| 94 | - - name: Run integration tests on Android | ||
| 95 | - if: contains(matrix.device, 'Android') && false # Need to run locally for now. | ||
| 96 | - uses: reactivecircus/android-emulator-runner@v2.5.0 | ||
| 97 | - with: | ||
| 98 | - api-level: 29 | ||
| 99 | - disable-animations: false | ||
| 100 | - script: cd example && flutter drive --target=test_driver/app.dart | 98 | + cd wakelock/example |
| 99 | + flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart |
| @@ -11,15 +11,25 @@ on: | @@ -11,15 +11,25 @@ on: | ||
| 11 | - '**/pubspec.yaml' | 11 | - '**/pubspec.yaml' |
| 12 | - '**/test/**' | 12 | - '**/test/**' |
| 13 | - '**/test_driver/**' | 13 | - '**/test_driver/**' |
| 14 | + - '**/assets/**' | ||
| 15 | + - '**/integration_test/**' | ||
| 14 | 16 | ||
| 15 | jobs: | 17 | jobs: |
| 16 | configure: | 18 | configure: |
| 17 | - # Not using the conditional as jobs are not re-run when the draft status changes. | ||
| 18 | - #if: github.event.pull_request.draft == false | 19 | + timeout-minutes: 9 |
| 19 | runs-on: ubuntu-latest | 20 | runs-on: ubuntu-latest |
| 21 | + name: Configuration of ${{ matrix.package }} | ||
| 22 | + strategy: | ||
| 23 | + matrix: | ||
| 24 | + package: | ||
| 25 | + - 'wakelock' | ||
| 26 | + - 'wakelock_platform_interface' | ||
| 27 | + - 'wakelock_web' | ||
| 28 | + fail-fast: false | ||
| 20 | 29 | ||
| 21 | steps: | 30 | steps: |
| 22 | - uses: actions/checkout@v2.3.3 | 31 | - uses: actions/checkout@v2.3.3 |
| 23 | - uses: axel-op/dart-package-analyzer@v3 | 32 | - uses: axel-op/dart-package-analyzer@v3 |
| 24 | with: | 33 | with: |
| 34 | + relativePath: ${{ matrix.package }} | ||
| 25 | githubToken: ${{ secrets.GITHUB_TOKEN }} | 35 | githubToken: ${{ secrets.GITHUB_TOKEN }} |
| 1 | -name: Publish | 1 | +name: Publish packages and releases |
| 2 | 2 | ||
| 3 | on: | 3 | on: |
| 4 | push: | 4 | push: |
| 5 | branches: | 5 | branches: |
| 6 | - master | 6 | - master |
| 7 | + paths: | ||
| 8 | + # Can only publish the package when the Pubspec changed, i.e. specifically the package | ||
| 9 | + # version, however, we can ensure that this is the case in code review. | ||
| 10 | + - '*/pubspec.yaml' | ||
| 7 | 11 | ||
| 8 | jobs: | 12 | jobs: |
| 9 | - checks: | ||
| 10 | - runs-on: macos-latest | ||
| 11 | - name: Check format, analyze, and test | 13 | + pana: |
| 14 | + timeout-minutes: 9 | ||
| 15 | + runs-on: ubuntu-latest | ||
| 16 | + name: Configuration of ${{ matrix.package }} | ||
| 17 | + strategy: | ||
| 18 | + matrix: | ||
| 19 | + package: | ||
| 20 | + - 'wakelock' | ||
| 21 | + - 'wakelock_platform_interface' | ||
| 22 | + - 'wakelock_web' | ||
| 23 | + fail-fast: false | ||
| 12 | 24 | ||
| 13 | steps: | 25 | steps: |
| 14 | - uses: actions/checkout@v2.3.3 | 26 | - uses: actions/checkout@v2.3.3 |
| 15 | - - uses: subosito/flutter-action@v1.3.2 | ||
| 16 | - with: | ||
| 17 | - channel: stable | ||
| 18 | - - name: Setup projects (root & example) | ||
| 19 | - run: | | ||
| 20 | - flutter pub get | ||
| 21 | - cd example | ||
| 22 | - flutter create . | ||
| 23 | - rm -rf test | ||
| 24 | - flutter pub get | ||
| 25 | - cd .. | ||
| 26 | - - name: Check format | ||
| 27 | - run: flutter format . --set-exit-if-changed --fix | ||
| 28 | - - run: flutter analyze | ||
| 29 | - - name: Run unit tests | ||
| 30 | - run: flutter test | ||
| 31 | - - name: Run integration tests on Android | ||
| 32 | - if: false # Need to run locally for now. | ||
| 33 | - uses: reactivecircus/android-emulator-runner@v2.5.0 | 27 | + - uses: axel-op/dart-package-analyzer@v3 |
| 34 | with: | 28 | with: |
| 35 | - api-level: 29 | ||
| 36 | - disable-animations: false | ||
| 37 | - script: cd example && flutter drive --target=test_driver/app.dart | 29 | + relativePath: ${{ matrix.package }} |
| 30 | + githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
| 31 | + | ||
| 38 | publish: | 32 | publish: |
| 39 | - needs: checks | 33 | + needs: pana |
| 34 | + timeout-minutes: 2 | ||
| 40 | runs-on: ubuntu-latest | 35 | runs-on: ubuntu-latest |
| 41 | - name: Publish plugin | 36 | + name: Publishing of ${{ matrix.package }} |
| 37 | + strategy: | ||
| 38 | + matrix: | ||
| 39 | + package: | ||
| 40 | + - 'wakelock' | ||
| 41 | + - 'wakelock_platform_interface' | ||
| 42 | + - 'wakelock_web' | ||
| 43 | + fail-fast: false | ||
| 42 | 44 | ||
| 43 | steps: | 45 | steps: |
| 44 | - uses: actions/checkout@v2.3.3 | 46 | - uses: actions/checkout@v2.3.3 |
| 45 | - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 | 47 | - uses: sakebook/actions-flutter-pub-publisher@v1.3.1 |
| 46 | with: | 48 | with: |
| 49 | + relativePath: ${{ matrix.package }} | ||
| 47 | credential: ${{ secrets.PUB_CREDENTIALS }} | 50 | credential: ${{ secrets.PUB_CREDENTIALS }} |
| 48 | flutter_package: true | 51 | flutter_package: true |
| 49 | skip_test: true | 52 | skip_test: true |
| 53 | + | ||
| 54 | + tag-release: | ||
| 55 | + needs: publish | ||
| 56 | + timeout-minutes: 1 | ||
| 57 | + runs-on: ubuntu-latest | ||
| 58 | + name: Tagging of ${{ matrix.package }} | ||
| 59 | + strategy: | ||
| 60 | + matrix: | ||
| 61 | + package: | ||
| 62 | + - wakelock | ||
| 63 | + - wakelock_web | ||
| 64 | + - wakelock_platform_interface | ||
| 65 | + | ||
| 66 | + steps: | ||
| 67 | + - uses: actions/checkout@v2 | ||
| 68 | + with: | ||
| 69 | + fetch-depth: 2 | ||
| 70 | + | ||
| 71 | + - name: Check package Pubspec | ||
| 72 | + id: pubspec | ||
| 73 | + run: | | ||
| 74 | + set +e | ||
| 75 | + git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep '${{ matrix.package }}/pubspec.yaml' &> /dev/null | ||
| 76 | + echo ::set-output name=changed::$? | ||
| 77 | + set -e | ||
| 78 | + - name: Extract package version | ||
| 79 | + if: steps.pubspec.outputs.changed == 0 | ||
| 80 | + run: | | ||
| 81 | + cd ${{ matrix.package }} | ||
| 82 | + echo ::set-env name=VERSION::"$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" | ||
| 83 | + - name: Create Release | ||
| 84 | + if: steps.pubspec.outputs.changed == 0 | ||
| 85 | + id: create_release | ||
| 86 | + uses: actions/create-release@v1.1.4 | ||
| 87 | + env: | ||
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| 89 | + with: | ||
| 90 | + tag_name: ${{ matrix.package }}-v${{ env.VERSION }} | ||
| 91 | + release_name: ${{ matrix.package }} v${{ env.VERSION }} | ||
| 92 | + draft: false | ||
| 93 | + prerelease: false |
.gitignore
deleted
100644 → 0
CODEOWNERS
deleted
100644 → 0
| 1 | -* @creativecreatorormaybenot |
CONTRIBUTING.md
deleted
100644 → 0
| 1 | -# Steps | ||
| 2 | - | ||
| 3 | -The following steps are based on a version of [flutter/plugin's contributing guide](https://github.com/flutter/plugins/blob/2ea66626c245a4373a6e07706ab2e7d471e25bd6/CONTRIBUTING.md). | ||
| 4 | - | ||
| 5 | -## Creating a fork | ||
| 6 | - | ||
| 7 | - * If you have not yet configured your machine with an SSH key that is known to GitHub, then follow [GitHub's directions](https://help.github.com/articles/generating-ssh-keys/) to generate an SSH key. | ||
| 8 | - * Fork [this repository](https://github.com/creativecreatorormaybenot/wakelock) using the "Fork" button in the upper right corner of the repository's GitHub page. | ||
| 9 | - * `git clone git@github.com:<github_user_name>/wakelock.git` | ||
| 10 | - * `cd wakelock` | ||
| 11 | - * `git remote add upstream git@github.com:creativecreatorormaybenot/wakelock.git` | ||
| 12 | - This ensures that `git fetch upstream` is possible to fetch from this remote repository instead of from your own fork to get the latest changes. | ||
| 13 | - | ||
| 14 | -## Creating a patch | ||
| 15 | - | ||
| 16 | - * `git fetch upstream` | ||
| 17 | - * `git checkout upstream/master -b <name_of_your_branch>` | ||
| 18 | - * Now, you can change the code necessary for your patch. | ||
| 19 | - | ||
| 20 | - Make sure that you bump the version in [`pubspec.yaml`](https://github.com/creativecreatorormaybenot/wakelock/blob/master/pubspec.yaml) | ||
| 21 | - and add an entry to [`CHANGELOG.md`](https://github.com/creativecreatorormaybenot/wakelock/blob/master/CHANGELOG.md). | ||
| 22 | - The version format is `r.M.m+p`. You will want to increment one of these values and which one you increment depends on the impact of your patch: | ||
| 23 | - `p` for simple patches, `m` for minor versions, `M` for major versions, and `r` for released. Do not forget to reset the values to the right of the value you incremented to 0. You should omit `+0`. | ||
| 24 | - * `git commit -am "<commit_message>"` | ||
| 25 | - * `git push origin <name_of_your_branch>` | ||
| 26 | - | ||
| 27 | -After having followed these steps, you are ready to [create a pull request](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork). | ||
| 28 | -The GitHub interface makes this very easy by providing a button on your fork page that creates a pull request with changes from a recently pushed to branch. | ||
| 29 | -Alternatively, you can also use `git pull-request` via [GitHub hub](https://hub.github.com/). | ||
| 30 | - | ||
| 31 | -# Notes | ||
| 32 | - | ||
| 33 | - * You should remember to exclude all files and directories your IDE might generate using the `.gitignore` files (if they do not already contain them for your IDE). | ||
| 34 | - If you feel like you can make useful additions to any of the `.gitignore` files, you can include them in your pull request, potentially with an explanation. | ||
| 35 | - | ||
| 36 | - * It is probably easier for you to run the integration tests for the plugin locally using `flutter drive --target=test_driver/app.dart` in the `example` directory | ||
| 37 | - before opening a pull request (CI also runs the integration tests). | ||
| 38 | - This way you can ensure that any changes you have made work properly. Furthermore, you might also want to add some tests if you implement new functionality. | ||
| 39 | - | ||
| 40 | - * You should also run `flutter format lib example --fix` in the root directory and make sure that `flutter analyze` does not report any errors. |
| 1 | -# Wakelock [](https://github.com/creativecreatorormaybenot/wakelock/actions) [](https://github.com/creativecreatorormaybenot/wakelock) [](https://pub.dev/packages/wakelock) | 1 | +# Wakelock [](https://github.com/creativecreatorormaybenot/wakelock/actions) [](https://github.com/creativecreatorormaybenot/wakelock) [](https://pub.dev/packages/wakelock) |
| 2 | 2 | ||
| 3 | -This Flutter plugin allows you to enable and toggle the screen wakelock on Android and iOS, which prevents the screen from turning off automatically. | ||
| 4 | -Essentially, this allows you to keep the device awake, i.e. prevent the device from sleeping. | 3 | +Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. |
| 5 | 4 | ||
| 6 | -## Usage | 5 | +## Getting started |
| 7 | 6 | ||
| 8 | -To use this plugin, follow the [installing guide](https://pub.dev/packages/wakelock#-installing-tab-). | 7 | +To learn more about the plugin and getting started, you can view [the main package (`wakelock`) README](https://github.com/creativecreatorormaybenot/wakelock/blob/master/wakelock/README.md). |
| 9 | 8 | ||
| 10 | -### Implementation | 9 | +### Plugin structure |
| 11 | 10 | ||
| 12 | -Everything in this plugin is controlled via the [`Wakelock` class](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock-class.html). | ||
| 13 | -If you want to enable the wakelock, i.e. keep the device awake, you can simply call [`Wakelock.enable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/enable.html) | ||
| 14 | -and to disable it again, you can use [`Wakelock.disable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/disable.html): | 11 | +The `wakelock` plugin uses the [federated plugins approach](https://flutter.dev/docs/development/packages-and-plugins/developing-packages#federated-plugins). |
| 12 | +For this plugin, it means that the basic API is defined using [`pigeon`](https://pub.dev/packages/pigeon). The pigeon files can be found in the [`pigeons` directory](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock/pigeons) | ||
| 13 | +in the main package. The API is defined in Dart in the [`wakelock_platform_interface` package](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface). | ||
| 14 | +Furthermore, the Android and iOS implementations can be found in the main package, while the web implementation is in the [`wakelock_web` package](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface). | ||
| 15 | 15 | ||
| 16 | -```dart | ||
| 17 | -import 'package:wakelock/wakelock.dart'; | ||
| 18 | -// ... | 16 | +The packages in this repo are the following: |
| 19 | 17 | ||
| 20 | -// The following line will enable the Android and iOS wakelock. | ||
| 21 | -Wakelock.enable(); | 18 | +| Package | Implementations | |
| 19 | +| ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------- | | ||
| 20 | +| [`wakelock`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock) | Main plugin package + Android & iOS implementations | | ||
| 21 | +| [`wakelock_platform_interface`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface) | Basic API definition & message handling | | ||
| 22 | +| [`wakelock_web`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_web) | Web implementation | | ||
| 22 | 23 | ||
| 23 | -// The next line disables the wakelock again. | ||
| 24 | -Wakelock.disable(); | ||
| 25 | -``` | 24 | +## Contributing |
| 26 | 25 | ||
| 27 | -For more advanced usage, you can pass a `bool` to [`Wakelock.toggle`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/toggle.html) to enable or disable the wakelock | ||
| 28 | -and also retrieve the current wakelock status using [`Wakelock.isEnabled`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/isEnabled.html): | 26 | +If you want to contribute to this plugin, follow the [contributing guide](https://github.com/creativecreatorormaybenot/wakelock/blob/master/.github/CONTRIBUTING.md). |
| 29 | 27 | ||
| 30 | -```dart | ||
| 31 | -import 'package:wakelock/wakelock.dart'; | ||
| 32 | -// ... | 28 | +## Origin |
| 33 | 29 | ||
| 34 | -// The following lines of code toggle the wakelock based on a bool value. | ||
| 35 | -bool on = true; | ||
| 36 | -// The following statement enables the wakelock. | ||
| 37 | -Wakelock.toggle(on: on); | ||
| 38 | - | ||
| 39 | -on = false; | ||
| 40 | -// The following statement disables the wakelock. | ||
| 41 | -Wakelock.toggle(on: on); | ||
| 42 | - | ||
| 43 | -// If you want to retrieve the current wakelock status, | ||
| 44 | -// you will have to be in an async scope | ||
| 45 | -// to await the Future returned by isEnabled. | ||
| 46 | -bool isEnabled = await Wakelock.isEnabled; | ||
| 47 | -``` | ||
| 48 | - | ||
| 49 | -If you want to wait for the wakelock toggle on Android or iOS to complete (which takes an insignificant amount of time), | ||
| 50 | -you can also `await` any of `Wakelock.enable`, `Wakelock.disable`, and `Wakelock.toggle`. | ||
| 51 | - | ||
| 52 | -## Notes | ||
| 53 | - | ||
| 54 | -This plugin is originally based on [`screen`](https://pub.dev/packages/screen). | 30 | +Originally, this plugin was based on [`screen`](https://pub.dev/packages/screen). |
| 55 | Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance by the author of the `screen` plugin. | 31 | Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance by the author of the `screen` plugin. |
| 56 | 32 | ||
| 57 | -If you want to contribute to this plugin, follow the [contributing guide](https://github.com/creativecreatorormaybenot/wakelock/blob/master/CONTRIBUTING.md). | 33 | +Today, the `wakelock` plugin has been completely refreshed (using latest Flutter standards and platform integration) with added web support. |
analysis_options.yaml
0 → 100644
android/.gitignore
deleted
100644 → 0
| 1 | -package creativecreatorormaybenot.wakelock | ||
| 2 | - | ||
| 3 | -import androidx.annotation.NonNull | ||
| 4 | -import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
| 5 | -import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
| 6 | -import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
| 7 | -import io.flutter.plugin.common.MethodCall | ||
| 8 | -import io.flutter.plugin.common.MethodChannel | ||
| 9 | -import io.flutter.plugin.common.MethodChannel.MethodCallHandler | ||
| 10 | -import io.flutter.plugin.common.MethodChannel.Result | ||
| 11 | -import io.flutter.plugin.common.PluginRegistry.Registrar | ||
| 12 | - | ||
| 13 | -public class WakelockPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { | ||
| 14 | - private lateinit var channel: MethodChannel | ||
| 15 | - | ||
| 16 | - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
| 17 | - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "wakelock") | ||
| 18 | - channel.setMethodCallHandler(this) | ||
| 19 | - wakelock = Wakelock() | ||
| 20 | - } | ||
| 21 | - | ||
| 22 | - private var registrar: Registrar? = null | ||
| 23 | - | ||
| 24 | - // This static function is optional and equivalent to onAttachedToEngine. It supports the old | ||
| 25 | - // pre-Flutter-1.12 Android projects. You are encouraged to continue supporting | ||
| 26 | - // plugin registration via this function while apps migrate to use the new Android APIs | ||
| 27 | - // post-flutter-1.12 via https://flutter.dev/go/android-project-migration. | ||
| 28 | - // | ||
| 29 | - // It is encouraged to share logic between onAttachedToEngine and registerWith to keep | ||
| 30 | - // them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called | ||
| 31 | - // depending on the user's project. onAttachedToEngine or registerWith must both be defined | ||
| 32 | - // in the same class. | ||
| 33 | - companion object { | ||
| 34 | - @JvmStatic | ||
| 35 | - fun registerWith(registrar: Registrar) { | ||
| 36 | - val channel = MethodChannel(registrar.messenger(), "wakelock") | ||
| 37 | - val plugin = WakelockPlugin() | ||
| 38 | - plugin.registrar = registrar | ||
| 39 | - plugin.wakelock = Wakelock() | ||
| 40 | - channel.setMethodCallHandler(plugin) | ||
| 41 | - } | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - private var wakelock: Wakelock? = null | ||
| 45 | - | ||
| 46 | - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { | ||
| 47 | - if (registrar != null) wakelock!!.activity = registrar!!.activity() | ||
| 48 | - when (call.method) { | ||
| 49 | - "toggle" -> { | ||
| 50 | - wakelock!!.toggle(call.argument<Boolean>("enable")!!, result) | ||
| 51 | - } | ||
| 52 | - "isEnabled" -> { | ||
| 53 | - wakelock!!.isEnabled(result) | ||
| 54 | - } | ||
| 55 | - else -> { | ||
| 56 | - result.notImplemented() | ||
| 57 | - } | ||
| 58 | - } | ||
| 59 | - if (registrar != null) wakelock!!.activity = null | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
| 63 | - channel.setMethodCallHandler(null) | ||
| 64 | - wakelock = null | ||
| 65 | - registrar = null | ||
| 66 | - } | ||
| 67 | - | ||
| 68 | - override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
| 69 | - wakelock?.activity = binding.activity | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - override fun onDetachedFromActivity() { | ||
| 73 | - wakelock?.activity = null | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
| 77 | - onAttachedToActivity(binding) | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - override fun onDetachedFromActivityForConfigChanges() { | ||
| 81 | - onDetachedFromActivity() | ||
| 82 | - } | ||
| 83 | -} |
example/README.md
deleted
100644 → 0
| 1 | -# Example | ||
| 2 | - | ||
| 3 | -This is a basic example demonstrating the functionality of the wakelock plugin, including enabling & disabling the wakelock and also retrieving the current wakelock status using a `FutureBuilder`. | ||
| 4 | - | ||
| 5 | -If you want to run this example app, you need to run `flutter create .` in the `example` directory (`cd example` from the plugin directory) first. This is also necessary when running the Flutter Driver tests. | ||
| 6 | - | ||
| 7 | -See [`example/lib/main.dart`](https://github.com/creativecreatorormaybenot/wakelock/blob/master/example/lib/main.dart). | ||
| 8 | - | ||
| 9 | -## Integration testing | ||
| 10 | - | ||
| 11 | -For integration testing, this plugin uses [`example/test_driver`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/example/test_driver). The project has a setup for continuous integration, which will run the integration tests to confirm that the plugin is working correctly. | ||
| 12 | -The status for the latest commit is [](https://travis-ci.com/creativecreatorormaybenot/wakelock). | ||
| 13 | - | ||
| 14 | -If you want to run the integration tests yourself, you can run `flutter drive --target=test_driver/app.dart` from the `example` directory. |
example/test_driver/app.dart
deleted
100644 → 0
| 1 | -import 'dart:async'; | ||
| 2 | - | ||
| 3 | -import 'package:flutter_driver/driver_extension.dart'; | ||
| 4 | -import 'package:test/test.dart'; | ||
| 5 | -import 'package:wakelock/wakelock.dart'; | ||
| 6 | -import 'package:wakelock_example/main.dart' as example; | ||
| 7 | - | ||
| 8 | -void main() { | ||
| 9 | - final completer = Completer<String>(); | ||
| 10 | - enableFlutterDriverExtension(handler: (message) => completer.future); | ||
| 11 | - // The example app tests need this. | ||
| 12 | - example.main(); | ||
| 13 | - | ||
| 14 | - var result = 'success'; | ||
| 15 | - | ||
| 16 | - final _expect = (dynamic value, Matcher matcher) { | ||
| 17 | - if (!matcher.matches(value, null)) { | ||
| 18 | - result = 'failure'; | ||
| 19 | - } | ||
| 20 | - expect(value, matcher); | ||
| 21 | - }; | ||
| 22 | - | ||
| 23 | - group('wakelock bare platform testing', () { | ||
| 24 | - tearDownAll(() => completer.complete(result)); | ||
| 25 | - | ||
| 26 | - test('toggle on', () async { | ||
| 27 | - await Wakelock.toggle(on: true); | ||
| 28 | - | ||
| 29 | - _expect(await Wakelock.isEnabled, isTrue); | ||
| 30 | - }); | ||
| 31 | - | ||
| 32 | - test('toggle off', () async { | ||
| 33 | - await Wakelock.toggle(on: false); | ||
| 34 | - | ||
| 35 | - _expect(await Wakelock.isEnabled, isFalse); | ||
| 36 | - }); | ||
| 37 | - }); | ||
| 38 | -} |
example/test_driver/app_test.dart
deleted
100644 → 0
| 1 | -import 'package:flutter_driver/flutter_driver.dart'; | ||
| 2 | -import 'package:test/test.dart'; | ||
| 3 | - | ||
| 4 | -void main() async { | ||
| 5 | - FlutterDriver driver; | ||
| 6 | - String bareTestingResult; | ||
| 7 | - | ||
| 8 | - setUpAll(() async { | ||
| 9 | - driver = await FlutterDriver.connect(); | ||
| 10 | - bareTestingResult = | ||
| 11 | - await driver.requestData('', timeout: const Duration(minutes: 1)); | ||
| 12 | - }); | ||
| 13 | - | ||
| 14 | - tearDownAll(() => driver?.close()); | ||
| 15 | - | ||
| 16 | - group('example app', () { | ||
| 17 | - test('wakelock is disabled at start', () async { | ||
| 18 | - await driver._expectEnabled(isFalse); | ||
| 19 | - }); | ||
| 20 | - | ||
| 21 | - test('enable wakelock', () async { | ||
| 22 | - // Use the button in the example app instead of a direct plugin call. | ||
| 23 | - await driver.tap(find.text('enable wakelock')); | ||
| 24 | - | ||
| 25 | - await driver._expectEnabled(isTrue); | ||
| 26 | - }); | ||
| 27 | - | ||
| 28 | - test('disable wakelock', () async { | ||
| 29 | - // Use the button in the example app instead of a direct plugin call. | ||
| 30 | - await driver.tap(find.text('disable wakelock')); | ||
| 31 | - | ||
| 32 | - await driver._expectEnabled(isFalse); | ||
| 33 | - }); | ||
| 34 | - }); | ||
| 35 | - | ||
| 36 | - test('wakelock bare platform testing', () async { | ||
| 37 | - expect(bareTestingResult, equals('success')); | ||
| 38 | - }); | ||
| 39 | -} | ||
| 40 | - | ||
| 41 | -extension on FlutterDriver { | ||
| 42 | - Future<bool> _finds(SerializableFinder finder) async { | ||
| 43 | - try { | ||
| 44 | - await waitFor(finder, timeout: const Duration(milliseconds: 420)); | ||
| 45 | - return true; | ||
| 46 | - } catch (_) { | ||
| 47 | - return false; | ||
| 48 | - } | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - Future<void> _expectEnabled(Matcher matcher) async { | ||
| 52 | - // Check the widget in the example app. | ||
| 53 | - final result = await _finds(find.text( | ||
| 54 | - 'wakelock is currently ${matcher == isTrue ? 'enabled' : 'disabled'}')); | ||
| 55 | - | ||
| 56 | - expect(result, isTrue); | ||
| 57 | - } | ||
| 58 | -} |
ios/Classes/WakelockPlugin.m
deleted
100644 → 0
| 1 | -#import "WakelockPlugin.h" | ||
| 2 | - | ||
| 3 | -@implementation WakelockPlugin | ||
| 4 | -+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { | ||
| 5 | - FlutterMethodChannel* channel = [FlutterMethodChannel | ||
| 6 | - methodChannelWithName:@"wakelock" | ||
| 7 | - binaryMessenger:[registrar messenger]]; | ||
| 8 | - WakelockPlugin* instance = [[WakelockPlugin alloc] init]; | ||
| 9 | - [registrar addMethodCallDelegate:instance channel:channel]; | ||
| 10 | -} | ||
| 11 | - | ||
| 12 | -- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { | ||
| 13 | - if ([@"toggle" isEqualToString:call.method]) { | ||
| 14 | - NSNumber *enable = call.arguments[@"enable"]; | ||
| 15 | - NSNumber *enabled = [NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]; | ||
| 16 | - | ||
| 17 | - if([enable isEqualToNumber:enabled]) { | ||
| 18 | - result(nil); | ||
| 19 | - } else { | ||
| 20 | - [[UIApplication sharedApplication] setIdleTimerDisabled:enable.boolValue]; | ||
| 21 | - result(nil); | ||
| 22 | - } | ||
| 23 | - } else if ([@"isEnabled" isEqualToString:call.method]) { | ||
| 24 | - result([NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]); | ||
| 25 | - } else { | ||
| 26 | - result(FlutterMethodNotImplemented); | ||
| 27 | - } | ||
| 28 | -} | ||
| 29 | - | ||
| 30 | -@end |
lib/wakelock.dart
deleted
100644 → 0
| 1 | -import 'dart:async'; | ||
| 2 | - | ||
| 3 | -import 'package:flutter/foundation.dart'; | ||
| 4 | -import 'package:flutter/services.dart'; | ||
| 5 | - | ||
| 6 | -/// To enable the wakelock, you can use [Wakelock.enable] and to disable it, | ||
| 7 | -/// you can call [Wakelock.disable]. | ||
| 8 | -/// You do not need to worry about making redundant calls, e.g. calling [Wakelock.enable] | ||
| 9 | -/// when the wakelock is already enabled as the plugin handles this for you, i.e. it checks | ||
| 10 | -/// the status to determine if the wakelock is already enabled or disabled. | ||
| 11 | -/// If you want the flexibility to pass a [bool] to control whether the wakelock should be | ||
| 12 | -/// enabled or disabled, you can use [Wakelock.toggle]. | ||
| 13 | -/// | ||
| 14 | -/// The [Wakelock.isEnabled] property allows you to retrieve the current wakelock | ||
| 15 | -/// status from Android or iOS. | ||
| 16 | -class Wakelock { | ||
| 17 | - static const MethodChannel _channel = MethodChannel('wakelock'); | ||
| 18 | - | ||
| 19 | - /// This can simply be called using `Wakelock.enable()` and does not return anything. | ||
| 20 | - /// You can await the [Future] to wait for the operation to complete. | ||
| 21 | - static Future<void> enable() => | ||
| 22 | - _channel.invokeMethod('toggle', {'enable': true}); | ||
| 23 | - | ||
| 24 | - /// This can simply be called using `Wakelock.disable()` and does not return anything. | ||
| 25 | - /// You can await the [Future] to wait for the operation to complete. | ||
| 26 | - static Future<void> disable() => | ||
| 27 | - _channel.invokeMethod('toggle', {'enable': false}); | ||
| 28 | - | ||
| 29 | - /// You can simply use this function to toggle the wakelock using a [bool] value. | ||
| 30 | - /// | ||
| 31 | - /// ```dart | ||
| 32 | - /// // This line keeps the screen on. | ||
| 33 | - /// Wakelock.toggle(on: true); | ||
| 34 | - /// | ||
| 35 | - /// bool turnOnWakelock = false; | ||
| 36 | - /// // The following line disables the wakelock. | ||
| 37 | - /// Wakelock.toggle(on: turnOnWakelock); | ||
| 38 | - /// ``` | ||
| 39 | - /// | ||
| 40 | - /// You can await the [Future] to wait for the operation to complete. | ||
| 41 | - static Future<void> toggle({@required bool on}) { | ||
| 42 | - assert(on != null, | ||
| 43 | - 'The [on] parameter cannot be null when toggling the wakelock.'); | ||
| 44 | - return _channel.invokeMethod('toggle', {'enable': on}); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - /// If you want to retrieve the current wakelock status, you will have to call [Wakelock.isEnabled] | ||
| 48 | - /// and await its result: `bool isEnabled = await Wakelock.isEnabled()` | ||
| 49 | - static Future<bool> get isEnabled => _channel.invokeMethod('isEnabled'); | ||
| 50 | -} |
test/wakelock_test.dart
deleted
100644 → 0
| 1 | -import 'package:flutter/services.dart'; | ||
| 2 | -import 'package:flutter_test/flutter_test.dart'; | ||
| 3 | -import 'package:wakelock/wakelock.dart'; | ||
| 4 | - | ||
| 5 | -void main() { | ||
| 6 | - const MethodChannel channel = MethodChannel('wakelock'); | ||
| 7 | - | ||
| 8 | - TestWidgetsFlutterBinding.ensureInitialized(); | ||
| 9 | - | ||
| 10 | - setUp(() { | ||
| 11 | - var enabled = false; | ||
| 12 | - | ||
| 13 | - channel.setMockMethodCallHandler((MethodCall methodCall) async { | ||
| 14 | - switch (methodCall.method) { | ||
| 15 | - case 'toggle': | ||
| 16 | - enabled = methodCall.arguments['enable']; | ||
| 17 | - break; | ||
| 18 | - case 'enable': | ||
| 19 | - enabled = true; | ||
| 20 | - break; | ||
| 21 | - case 'disable': | ||
| 22 | - enabled = false; | ||
| 23 | - break; | ||
| 24 | - case 'isEnabled': | ||
| 25 | - return enabled; | ||
| 26 | - default: | ||
| 27 | - throw ArgumentError.value(methodCall.method); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - return null; | ||
| 31 | - }); | ||
| 32 | - }); | ||
| 33 | - | ||
| 34 | - tearDown(() { | ||
| 35 | - channel.setMockMethodCallHandler(null); | ||
| 36 | - }); | ||
| 37 | - | ||
| 38 | - test('isEnabled', () async { | ||
| 39 | - expect(await Wakelock.isEnabled, isFalse); | ||
| 40 | - }); | ||
| 41 | - | ||
| 42 | - group('toggle', () { | ||
| 43 | - test('on', () async { | ||
| 44 | - await Wakelock.toggle(on: true); | ||
| 45 | - expect(await Wakelock.isEnabled, isTrue); | ||
| 46 | - }); | ||
| 47 | - | ||
| 48 | - test('off', () async { | ||
| 49 | - await Wakelock.toggle(on: false); | ||
| 50 | - expect(await Wakelock.isEnabled, isFalse); | ||
| 51 | - }); | ||
| 52 | - | ||
| 53 | - test('non-null assertion', () async { | ||
| 54 | - expect(() async => await Wakelock.toggle(on: null), throwsAssertionError); | ||
| 55 | - }); | ||
| 56 | - }); | ||
| 57 | - | ||
| 58 | - test('enable', () async { | ||
| 59 | - await Wakelock.enable(); | ||
| 60 | - expect(await Wakelock.isEnabled, isTrue); | ||
| 61 | - }); | ||
| 62 | - | ||
| 63 | - test('disable', () async { | ||
| 64 | - await Wakelock.disable(); | ||
| 65 | - expect(await Wakelock.isEnabled, isFalse); | ||
| 66 | - }); | ||
| 67 | -} |
wakelock/.gitignore
0 → 100644
| 1 | +# Miscellaneous | ||
| 2 | +*.class | ||
| 3 | +*.log | ||
| 4 | +*.pyc | ||
| 5 | +*.swp | ||
| 6 | +.DS_Store | ||
| 7 | +.atom/ | ||
| 8 | +.buildlog/ | ||
| 9 | +.history | ||
| 10 | +.svn/ | ||
| 11 | +.metadata | ||
| 12 | + | ||
| 13 | +# IntelliJ related | ||
| 14 | +*.iml | ||
| 15 | +*.ipr | ||
| 16 | +*.iws | ||
| 17 | +.idea/ | ||
| 18 | + | ||
| 19 | +# The .vscode folder contains launch configuration and tasks you configure in | ||
| 20 | +# VS Code which you may wish to be included in version control, so this line | ||
| 21 | +# is commented out by default. | ||
| 22 | +#.vscode/ | ||
| 23 | + | ||
| 24 | +# Flutter/Dart/Pub related | ||
| 25 | +**/doc/api/ | ||
| 26 | +.dart_tool/ | ||
| 27 | +.flutter-plugins | ||
| 28 | +.flutter-plugins-dependencies | ||
| 29 | +.packages | ||
| 30 | +.pub-cache/ | ||
| 31 | +.pub/ | ||
| 32 | +build/ | ||
| 33 | +pubspec.lock | ||
| 34 | + | ||
| 35 | +# Android related | ||
| 36 | +**/android/**/gradle-wrapper.jar | ||
| 37 | +**/android/.gradle | ||
| 38 | +**/android/captures/ | ||
| 39 | +**/android/gradlew | ||
| 40 | +**/android/gradlew.bat | ||
| 41 | +**/android/local.properties | ||
| 42 | +**/android/**/GeneratedPluginRegistrant.java | ||
| 43 | + | ||
| 44 | +# iOS/XCode related | ||
| 45 | +**/ios/**/*.mode1v3 | ||
| 46 | +**/ios/**/*.mode2v3 | ||
| 47 | +**/ios/**/*.moved-aside | ||
| 48 | +**/ios/**/*.pbxuser | ||
| 49 | +**/ios/**/*.perspectivev3 | ||
| 50 | +**/ios/**/*sync/ | ||
| 51 | +**/ios/**/.sconsign.dblite | ||
| 52 | +**/ios/**/.tags* | ||
| 53 | +**/ios/**/.vagrant/ | ||
| 54 | +**/ios/**/DerivedData/ | ||
| 55 | +**/ios/**/Icon? | ||
| 56 | +**/ios/**/Pods/ | ||
| 57 | +**/ios/**/.symlinks/ | ||
| 58 | +**/ios/**/profile | ||
| 59 | +**/ios/**/xcuserdata | ||
| 60 | +**/ios/.generated/ | ||
| 61 | +**/ios/Flutter/App.framework | ||
| 62 | +**/ios/Flutter/Flutter.framework | ||
| 63 | +**/ios/Flutter/Flutter.podspec | ||
| 64 | +**/ios/Flutter/Generated.xcconfig | ||
| 65 | +**/ios/Flutter/app.flx | ||
| 66 | +**/ios/Flutter/app.zip | ||
| 67 | +**/ios/Flutter/flutter_assets/ | ||
| 68 | +**/ios/Flutter/flutter_export_environment.sh | ||
| 69 | +**/ios/ServiceDefinitions.json | ||
| 70 | +**/ios/Runner/GeneratedPluginRegistrant.* | ||
| 71 | + | ||
| 72 | +# Exceptions to above rules. | ||
| 73 | +!**/ios/**/default.mode1v3 | ||
| 74 | +!**/ios/**/default.mode2v3 | ||
| 75 | +!**/ios/**/default.pbxuser | ||
| 76 | +!**/ios/**/default.perspectivev3 |
| 1 | +## 0.2.0 | ||
| 2 | + | ||
| 3 | +* Added web support. | ||
| 4 | +* Overhauled the plugin with the latest Flutter standards. | ||
| 5 | +* Implemented federated plugin approach, adding `wakelock_platform_interface` and `wakelock_web` | ||
| 6 | + dependencies. | ||
| 7 | +* Removed support for the Android v1 APIs. | ||
| 8 | +* *Deprecated* `Wakelock.isEnabled` in favor of `Wakelock.enabled`. The fact that it is a getter | ||
| 9 | + should be enough and remove the need for the "is" context. | ||
| 10 | +* *Deprecated* the `on` parameter in `Wakelock.toggle` in favor of the `enable` parameter, which | ||
| 11 | + should be a more descriptive name. | ||
| 12 | + | ||
| 1 | ## 0.1.4+2 | 13 | ## 0.1.4+2 |
| 2 | 14 | ||
| 3 | * Fixed Gradle builds missing NonNull annotation. | 15 | * Fixed Gradle builds missing NonNull annotation. |
wakelock/README.md
0 → 100644
| 1 | +# wakelock [](https://pub.dev/packages/wakelock) [](https://github.com/creativecreatorormaybenot/wakelock) | ||
| 2 | + | ||
| 3 | +Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on | ||
| 4 | +Android, iOS, and web. | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + | ||
| 8 | +The plugin allows you to enable and toggle the screen wakelock on Android, iOS, and web, which | ||
| 9 | +prevents the screen from turning off automatically. | ||
| 10 | +Essentially, this allows you to keep the device awake, i.e. prevent the device from sleeping. | ||
| 11 | + | ||
| 12 | +## Usage | ||
| 13 | + | ||
| 14 | +To use this plugin, follow the [installing guide](https://pub.dev/packages/wakelock/install). | ||
| 15 | + | ||
| 16 | +### Implementation | ||
| 17 | + | ||
| 18 | +Everything in this plugin is controlled via the [`Wakelock` class](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock-class.html). | ||
| 19 | +If you want to enable the wakelock, i.e. keep the device awake, you can simply call [`Wakelock.enable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/enable.html) | ||
| 20 | +and to disable it again, you can use [`Wakelock.disable`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/disable.html): | ||
| 21 | + | ||
| 22 | +```dart | ||
| 23 | +import 'package:wakelock/wakelock.dart'; | ||
| 24 | +// ... | ||
| 25 | + | ||
| 26 | +// The following line will enable the Android and iOS wakelock. | ||
| 27 | +Wakelock.enable(); | ||
| 28 | + | ||
| 29 | +// The next line disables the wakelock again. | ||
| 30 | +Wakelock.disable(); | ||
| 31 | +``` | ||
| 32 | + | ||
| 33 | +For more advanced usage, you can pass a `bool` to [`Wakelock.toggle`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/toggle.html) | ||
| 34 | +to enable or disable the wakelock and also retrieve the current wakelock status using | ||
| 35 | +[`Wakelock.isEnabled`](https://pub.dev/documentation/wakelock/latest/wakelock/Wakelock/isEnabled.html): | ||
| 36 | + | ||
| 37 | +```dart | ||
| 38 | +import 'package:wakelock/wakelock.dart'; | ||
| 39 | +// ... | ||
| 40 | + | ||
| 41 | +// The following lines of code toggle the wakelock based on a bool value. | ||
| 42 | +bool enable = true; | ||
| 43 | +// The following statement enables the wakelock. | ||
| 44 | +Wakelock.toggle(enable: enable); | ||
| 45 | + | ||
| 46 | +enable = false; | ||
| 47 | +// The following statement disables the wakelock. | ||
| 48 | +Wakelock.toggle(enable: enable); | ||
| 49 | + | ||
| 50 | +// If you want to retrieve the current wakelock status, | ||
| 51 | +// you will have to be in an async scope | ||
| 52 | +// to await the Future returned by `enabled`. | ||
| 53 | +bool wakelockEnabled = await Wakelock.enabled; | ||
| 54 | +``` | ||
| 55 | + | ||
| 56 | +If you want to wait for the wakelock toggle to complete (which takes an insignificant amount of | ||
| 57 | +time), you can also `await` any of `Wakelock.enable`, `Wakelock.disable`, and `Wakelock.toggle`. | ||
| 58 | + | ||
| 59 | +## Learn more | ||
| 60 | + | ||
| 61 | +If you want to learn more about how this plugin works, how to contribute, etc., you can read through | ||
| 62 | +the [main README on GitHub](https://github.com/creativecreatorormaybenot/wakelock). |
wakelock/android/.gitignore
0 → 100644
| 1 | -group 'creativecreatorormaybenot.wakelock' | 1 | +group 'creativemaybeno.wakelock' |
| 2 | version '1.0-SNAPSHOT' | 2 | version '1.0-SNAPSHOT' |
| 3 | 3 | ||
| 4 | buildscript { | 4 | buildscript { |
| @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' | @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' | ||
| 25 | apply plugin: 'kotlin-android' | 25 | apply plugin: 'kotlin-android' |
| 26 | 26 | ||
| 27 | android { | 27 | android { |
| 28 | - compileSdkVersion 28 | 28 | + compileSdkVersion 29 |
| 29 | 29 | ||
| 30 | sourceSets { | 30 | sourceSets { |
| 31 | main.java.srcDirs += 'src/main/kotlin' | 31 | main.java.srcDirs += 'src/main/kotlin' |
| @@ -40,5 +40,4 @@ android { | @@ -40,5 +40,4 @@ android { | ||
| 40 | 40 | ||
| 41 | dependencies { | 41 | dependencies { |
| 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | 42 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" |
| 43 | - implementation "androidx.annotation:annotation:1.1.0" | ||
| 44 | } | 43 | } |
wakelock/android/gradle.properties
0 → 100644
| 1 | +// Autogenerated from Pigeon (v0.1.7), do not edit directly. | ||
| 2 | +// See also: https://pub.dev/packages/pigeon | ||
| 3 | +package creativemaybeno.wakelock | ||
| 4 | + | ||
| 5 | +import io.flutter.plugin.common.BasicMessageChannel | ||
| 6 | +import io.flutter.plugin.common.BinaryMessenger | ||
| 7 | +import io.flutter.plugin.common.StandardMessageCodec | ||
| 8 | +import java.util.* | ||
| 9 | + | ||
| 10 | +/** Generated class from Pigeon. */ | ||
| 11 | +object Messages { | ||
| 12 | + private fun wrapError(exception: Exception): HashMap<*, *> { | ||
| 13 | + val errorMap = HashMap<String, Any?>() | ||
| 14 | + errorMap["message"] = exception.toString() | ||
| 15 | + errorMap["code"] = null | ||
| 16 | + errorMap["details"] = null | ||
| 17 | + return errorMap | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** Generated class from Pigeon that represents data sent in messages. */ | ||
| 21 | + class ToggleMessage { | ||
| 22 | + private var enable: Boolean? = null | ||
| 23 | + fun getEnable(): Boolean? { | ||
| 24 | + return enable | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + fun setEnable(setterArg: Boolean?) { | ||
| 28 | + enable = setterArg | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + fun toMap(): HashMap<*, *> { | ||
| 32 | + val toMapResult = HashMap<String, Any?>() | ||
| 33 | + toMapResult["enable"] = enable | ||
| 34 | + return toMapResult | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + companion object { | ||
| 38 | + fun fromMap(map: HashMap<*, *>?): ToggleMessage { | ||
| 39 | + val fromMapResult = ToggleMessage() | ||
| 40 | + val enable = map!!["enable"] | ||
| 41 | + fromMapResult.enable = enable as Boolean? | ||
| 42 | + return fromMapResult | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + /** Generated class from Pigeon that represents data sent in messages. */ | ||
| 48 | + class IsEnabledMessage { | ||
| 49 | + private var enabled: Boolean? = null | ||
| 50 | + fun getEnabled(): Boolean? { | ||
| 51 | + return enabled | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + fun setEnabled(setterArg: Boolean?) { | ||
| 55 | + enabled = setterArg | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + fun toMap(): HashMap<*, *> { | ||
| 59 | + val toMapResult = HashMap<String, Any?>() | ||
| 60 | + toMapResult["enabled"] = enabled | ||
| 61 | + return toMapResult | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + companion object { | ||
| 65 | + fun fromMap(map: HashMap<*, *>): IsEnabledMessage { | ||
| 66 | + val fromMapResult = IsEnabledMessage() | ||
| 67 | + val enabled = map["enabled"] | ||
| 68 | + fromMapResult.enabled = enabled as Boolean? | ||
| 69 | + return fromMapResult | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ | ||
| 75 | + interface WakelockApi { | ||
| 76 | + fun toggle(arg: ToggleMessage?) | ||
| 77 | + val isEnabled: IsEnabledMessage | ||
| 78 | + | ||
| 79 | + companion object { | ||
| 80 | + /** Sets up an instance of `WakelockApi` to handle messages through the `binaryMessenger` */ | ||
| 81 | + fun setup(binaryMessenger: BinaryMessenger?, api: WakelockApi?) { | ||
| 82 | + run { | ||
| 83 | + val channel = BasicMessageChannel(binaryMessenger!!, "dev.flutter.pigeon.WakelockApi.toggle", StandardMessageCodec()) | ||
| 84 | + if (api != null) { | ||
| 85 | + channel.setMessageHandler { message: Any?, reply: BasicMessageChannel.Reply<Any> -> | ||
| 86 | + val wrapped = HashMap<String, HashMap<*, *>?>() | ||
| 87 | + try { | ||
| 88 | + val input = ToggleMessage.fromMap(message as HashMap<*, *>?) | ||
| 89 | + api.toggle(input) | ||
| 90 | + wrapped["result"] = null | ||
| 91 | + } catch (exception: Exception) { | ||
| 92 | + wrapped["error"] = wrapError(exception) | ||
| 93 | + } | ||
| 94 | + reply.reply(wrapped) | ||
| 95 | + } | ||
| 96 | + } else { | ||
| 97 | + channel.setMessageHandler(null) | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + run { | ||
| 101 | + val channel = BasicMessageChannel(binaryMessenger!!, "dev.flutter.pigeon.WakelockApi.isEnabled", StandardMessageCodec()) | ||
| 102 | + if (api != null) { | ||
| 103 | + channel.setMessageHandler { message: Any?, reply: BasicMessageChannel.Reply<Any> -> | ||
| 104 | + val wrapped = HashMap<String, HashMap<*, *>>() | ||
| 105 | + try { | ||
| 106 | + val output = api.isEnabled | ||
| 107 | + wrapped["result"] = output.toMap() | ||
| 108 | + } catch (exception: Exception) { | ||
| 109 | + wrapped["error"] = wrapError(exception) | ||
| 110 | + } | ||
| 111 | + reply.reply(wrapped) | ||
| 112 | + } | ||
| 113 | + } else { | ||
| 114 | + channel.setMessageHandler(null) | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | +} |
| 1 | -package creativecreatorormaybenot.wakelock | 1 | +package creativemaybeno.wakelock |
| 2 | 2 | ||
| 3 | import android.app.Activity | 3 | import android.app.Activity |
| 4 | import android.view.WindowManager | 4 | import android.view.WindowManager |
| 5 | -import io.flutter.plugin.common.MethodChannel | 5 | +import creativemaybeno.wakelock.Messages.IsEnabledMessage |
| 6 | +import creativemaybeno.wakelock.Messages.ToggleMessage | ||
| 6 | 7 | ||
| 7 | internal class Wakelock { | 8 | internal class Wakelock { |
| 8 | var activity: Activity? = null | 9 | var activity: Activity? = null |
| @@ -11,32 +12,30 @@ internal class Wakelock { | @@ -11,32 +12,30 @@ internal class Wakelock { | ||
| 11 | get() = activity!!.window.attributes.flags and | 12 | get() = activity!!.window.attributes.flags and |
| 12 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON != 0 | 13 | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON != 0 |
| 13 | 14 | ||
| 14 | - fun toggle(enable: Boolean, result: MethodChannel.Result) { | 15 | + fun toggle(message: ToggleMessage) { |
| 15 | if (activity == null) { | 16 | if (activity == null) { |
| 16 | - result.noActivity() | ||
| 17 | - return | 17 | + throw NoActivityException() |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | val activity = this.activity!! | 20 | val activity = this.activity!! |
| 21 | val enabled = this.enabled | 21 | val enabled = this.enabled |
| 22 | 22 | ||
| 23 | - if (enable) { | 23 | + if (message.getEnable()!!) { |
| 24 | if (!enabled) activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) | 24 | if (!enabled) activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) |
| 25 | } else if (enabled) { | 25 | } else if (enabled) { |
| 26 | activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) | 26 | activity.window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) |
| 27 | } | 27 | } |
| 28 | - | ||
| 29 | - result.success(null) | ||
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | - fun isEnabled(result: MethodChannel.Result) { | 30 | + fun isEnabled(): IsEnabledMessage { |
| 33 | if (activity == null) { | 31 | if (activity == null) { |
| 34 | - result.noActivity() | ||
| 35 | - return | 32 | + throw NoActivityException() |
| 36 | } | 33 | } |
| 37 | 34 | ||
| 38 | - result.success(enabled) | 35 | + val msg = IsEnabledMessage() |
| 36 | + msg.setEnabled(enabled) | ||
| 37 | + return msg | ||
| 39 | } | 38 | } |
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | -fun MethodChannel.Result.noActivity() = error("no_activity", "wakelock requires a foreground activity", null) | 41 | +class NoActivityException() : Exception("wakelock requires a foreground activity") |
| 1 | +package creativemaybeno.wakelock | ||
| 2 | + | ||
| 3 | +import androidx.annotation.NonNull | ||
| 4 | +import creativemaybeno.wakelock.Messages.IsEnabledMessage | ||
| 5 | +import creativemaybeno.wakelock.Messages.ToggleMessage | ||
| 6 | +import creativemaybeno.wakelock.Messages.WakelockApi | ||
| 7 | +import io.flutter.embedding.engine.plugins.FlutterPlugin | ||
| 8 | +import io.flutter.embedding.engine.plugins.activity.ActivityAware | ||
| 9 | +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding | ||
| 10 | + | ||
| 11 | +/** WakelockPlugin */ | ||
| 12 | +class WakelockPlugin : FlutterPlugin, WakelockApi, ActivityAware { | ||
| 13 | + private var wakelock: Wakelock? = null | ||
| 14 | + | ||
| 15 | + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { | ||
| 16 | + WakelockApi.setup(flutterPluginBinding.binaryMessenger, this) | ||
| 17 | + wakelock = Wakelock() | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { | ||
| 21 | + WakelockApi.setup(binding.binaryMessenger, null) | ||
| 22 | + wakelock = null | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + override fun onAttachedToActivity(binding: ActivityPluginBinding) { | ||
| 26 | + wakelock?.activity = binding.activity | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + override fun onDetachedFromActivity() { | ||
| 30 | + wakelock?.activity = null | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { | ||
| 34 | + onAttachedToActivity(binding) | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + override fun onDetachedFromActivityForConfigChanges() { | ||
| 38 | + onDetachedFromActivity() | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + override fun toggle(arg: ToggleMessage?) { | ||
| 42 | + wakelock!!.toggle(arg!!) | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + override val isEnabled: IsEnabledMessage | ||
| 46 | + get() { | ||
| 47 | + return wakelock!!.isEnabled() | ||
| 48 | + } | ||
| 49 | +} |
| @@ -22,6 +22,7 @@ | @@ -22,6 +22,7 @@ | ||
| 22 | 22 | ||
| 23 | # Flutter/Dart/Pub related | 23 | # Flutter/Dart/Pub related |
| 24 | **/doc/api/ | 24 | **/doc/api/ |
| 25 | +**/ios/Flutter/.last_build_id | ||
| 25 | .dart_tool/ | 26 | .dart_tool/ |
| 26 | .flutter-plugins | 27 | .flutter-plugins |
| 27 | .flutter-plugins-dependencies | 28 | .flutter-plugins-dependencies |
| @@ -38,14 +39,3 @@ app.*.symbols | @@ -38,14 +39,3 @@ app.*.symbols | ||
| 38 | 39 | ||
| 39 | # Obfuscation related | 40 | # Obfuscation related |
| 40 | app.*.map.json | 41 | app.*.map.json |
| 41 | - | ||
| 42 | -# Exceptions to above rules. | ||
| 43 | -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages | ||
| 44 | - | ||
| 45 | -# Cleanliness | ||
| 46 | -pubspec.lock | ||
| 47 | -.metadata | ||
| 48 | -test | ||
| 49 | -ios | ||
| 50 | -android | ||
| 51 | -web |
wakelock/example/README.md
0 → 100644
| 1 | +# wakelock_example | ||
| 2 | + | ||
| 3 | +Example app demonstrating how to use the wakelock plugin. It also includes integration tests for | ||
| 4 | +testing the plugin in an integrated example. | ||
| 5 | + | ||
| 6 | +## Integration tests | ||
| 7 | + | ||
| 8 | +You can run the integration tests using the following command: | ||
| 9 | + | ||
| 10 | +``` | ||
| 11 | +flutter drive --driver=test_driver/integration_test.dart --target=integration_test/wakelock_test.dart | ||
| 12 | +``` |
wakelock/example/android/.gitignore
0 → 100644
wakelock/example/android/app/build.gradle
0 → 100644
| 1 | +def localProperties = new Properties() | ||
| 2 | +def localPropertiesFile = rootProject.file('local.properties') | ||
| 3 | +if (localPropertiesFile.exists()) { | ||
| 4 | + localPropertiesFile.withReader('UTF-8') { reader -> | ||
| 5 | + localProperties.load(reader) | ||
| 6 | + } | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +def flutterRoot = localProperties.getProperty('flutter.sdk') | ||
| 10 | +if (flutterRoot == null) { | ||
| 11 | + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') | ||
| 15 | +if (flutterVersionCode == null) { | ||
| 16 | + flutterVersionCode = '1' | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +def flutterVersionName = localProperties.getProperty('flutter.versionName') | ||
| 20 | +if (flutterVersionName == null) { | ||
| 21 | + flutterVersionName = '1.0' | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +apply plugin: 'com.android.application' | ||
| 25 | +apply plugin: 'kotlin-android' | ||
| 26 | +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" | ||
| 27 | + | ||
| 28 | +android { | ||
| 29 | + compileSdkVersion 29 | ||
| 30 | + | ||
| 31 | + sourceSets { | ||
| 32 | + main.java.srcDirs += 'src/main/kotlin' | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + lintOptions { | ||
| 36 | + disable 'InvalidPackage' | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + defaultConfig { | ||
| 40 | + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | ||
| 41 | + applicationId "creativemaybeno.wakelock_example" | ||
| 42 | + minSdkVersion 16 | ||
| 43 | + targetSdkVersion 29 | ||
| 44 | + versionCode flutterVersionCode.toInteger() | ||
| 45 | + versionName flutterVersionName | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + buildTypes { | ||
| 49 | + release { | ||
| 50 | + // TODO: Add your own signing config for the release build. | ||
| 51 | + // Signing with the debug keys for now, so `flutter run --release` works. | ||
| 52 | + signingConfig signingConfigs.debug | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +flutter { | ||
| 58 | + source '../..' | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +dependencies { | ||
| 62 | + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
| 63 | +} |
| 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + package="creativemaybeno.wakelock_example"> | ||
| 3 | + <!-- Flutter needs it to communicate with the running application | ||
| 4 | + to allow setting breakpoints, to provide hot reload, etc. | ||
| 5 | + --> | ||
| 6 | + <uses-permission android:name="android.permission.INTERNET"/> | ||
| 7 | +</manifest> |
| 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + package="creativemaybeno.wakelock_example"> | ||
| 3 | + <!-- io.flutter.app.FlutterApplication is an android.app.Application that | ||
| 4 | + calls FlutterMain.startInitialization(this); in its onCreate method. | ||
| 5 | + In most cases you can leave this as-is, but you if you want to provide | ||
| 6 | + additional functionality it is fine to subclass or reimplement | ||
| 7 | + FlutterApplication and put your custom class here. --> | ||
| 8 | + <application | ||
| 9 | + android:name="io.flutter.app.FlutterApplication" | ||
| 10 | + android:label="wakelock_example" | ||
| 11 | + android:icon="@mipmap/ic_launcher"> | ||
| 12 | + <activity | ||
| 13 | + android:name=".MainActivity" | ||
| 14 | + android:launchMode="singleTop" | ||
| 15 | + android:theme="@style/LaunchTheme" | ||
| 16 | + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" | ||
| 17 | + android:hardwareAccelerated="true" | ||
| 18 | + android:windowSoftInputMode="adjustResize"> | ||
| 19 | + <!-- Specifies an Android theme to apply to this Activity as soon as | ||
| 20 | + the Android process has started. This theme is visible to the user | ||
| 21 | + while the Flutter UI initializes. After that, this theme continues | ||
| 22 | + to determine the Window background behind the Flutter UI. --> | ||
| 23 | + <meta-data | ||
| 24 | + android:name="io.flutter.embedding.android.NormalTheme" | ||
| 25 | + android:resource="@style/NormalTheme" | ||
| 26 | + /> | ||
| 27 | + <!-- Displays an Android View that continues showing the launch screen | ||
| 28 | + Drawable until Flutter paints its first frame, then this splash | ||
| 29 | + screen fades out. A splash screen is useful to avoid any visual | ||
| 30 | + gap between the end of Android's launch screen and the painting of | ||
| 31 | + Flutter's first frame. --> | ||
| 32 | + <meta-data | ||
| 33 | + android:name="io.flutter.embedding.android.SplashScreenDrawable" | ||
| 34 | + android:resource="@drawable/launch_background" | ||
| 35 | + /> | ||
| 36 | + <intent-filter> | ||
| 37 | + <action android:name="android.intent.action.MAIN"/> | ||
| 38 | + <category android:name="android.intent.category.LAUNCHER"/> | ||
| 39 | + </intent-filter> | ||
| 40 | + </activity> | ||
| 41 | + <!-- Don't delete the meta-data below. | ||
| 42 | + This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> | ||
| 43 | + <meta-data | ||
| 44 | + android:name="flutterEmbedding" | ||
| 45 | + android:value="2" /> | ||
| 46 | + </application> | ||
| 47 | +</manifest> |
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<!-- Modify this file to customize your launch splash screen --> | ||
| 3 | +<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 4 | + <item android:drawable="@android:color/white" /> | ||
| 5 | + | ||
| 6 | + <!-- You can insert your own image assets here --> | ||
| 7 | + <!-- <item> | ||
| 8 | + <bitmap | ||
| 9 | + android:gravity="center" | ||
| 10 | + android:src="@mipmap/launch_image" /> | ||
| 11 | + </item> --> | ||
| 12 | +</layer-list> |
544 Bytes
442 Bytes
721 Bytes
1.01 KB
1.41 KB
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<resources> | ||
| 3 | + <!-- Theme applied to the Android Window while the process is starting --> | ||
| 4 | + <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar"> | ||
| 5 | + <!-- Show a splash screen on the activity. Automatically removed when | ||
| 6 | + Flutter draws its first frame --> | ||
| 7 | + <item name="android:windowBackground">@drawable/launch_background</item> | ||
| 8 | + </style> | ||
| 9 | + <!-- Theme applied to the Android Window as soon as the process has started. | ||
| 10 | + This theme determines the color of the Android Window while your | ||
| 11 | + Flutter UI initializes, as well as behind your Flutter UI while its | ||
| 12 | + running. | ||
| 13 | + | ||
| 14 | + This Theme is only used starting with V2 of Flutter's Android embedding. --> | ||
| 15 | + <style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar"> | ||
| 16 | + <item name="android:windowBackground">@android:color/white</item> | ||
| 17 | + </style> | ||
| 18 | +</resources> |
| 1 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 2 | + package="creativemaybeno.wakelock_example"> | ||
| 3 | + <!-- Flutter needs it to communicate with the running application | ||
| 4 | + to allow setting breakpoints, to provide hot reload, etc. | ||
| 5 | + --> | ||
| 6 | + <uses-permission android:name="android.permission.INTERNET"/> | ||
| 7 | +</manifest> |
wakelock/example/android/build.gradle
0 → 100644
| 1 | +buildscript { | ||
| 2 | + ext.kotlin_version = '1.3.50' | ||
| 3 | + repositories { | ||
| 4 | + google() | ||
| 5 | + jcenter() | ||
| 6 | + } | ||
| 7 | + | ||
| 8 | + dependencies { | ||
| 9 | + classpath 'com.android.tools.build:gradle:3.5.0' | ||
| 10 | + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
| 11 | + } | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +allprojects { | ||
| 15 | + repositories { | ||
| 16 | + google() | ||
| 17 | + jcenter() | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +rootProject.buildDir = '../build' | ||
| 22 | +subprojects { | ||
| 23 | + project.buildDir = "${rootProject.buildDir}/${project.name}" | ||
| 24 | +} | ||
| 25 | +subprojects { | ||
| 26 | + project.evaluationDependsOn(':app') | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +task clean(type: Delete) { | ||
| 30 | + delete rootProject.buildDir | ||
| 31 | +} |
wakelock/example/android/settings.gradle
0 → 100644
| 1 | +include ':app' | ||
| 2 | + | ||
| 3 | +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") | ||
| 4 | +def properties = new Properties() | ||
| 5 | + | ||
| 6 | +assert localPropertiesFile.exists() | ||
| 7 | +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } | ||
| 8 | + | ||
| 9 | +def flutterSdkPath = properties.getProperty("flutter.sdk") | ||
| 10 | +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" | ||
| 11 | +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" |
| 1 | +import 'package:flutter_test/flutter_test.dart'; | ||
| 2 | +import 'package:integration_test/integration_test.dart'; | ||
| 3 | +import 'package:wakelock/wakelock.dart'; | ||
| 4 | + | ||
| 5 | +void main() { | ||
| 6 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
| 7 | + | ||
| 8 | + testWidgets('enabling and disabling wakelock', (WidgetTester tester) async { | ||
| 9 | + final wakelockEnabled = await Wakelock.enabled; | ||
| 10 | + | ||
| 11 | + // The wakelock should initially be disabled. | ||
| 12 | + expect(wakelockEnabled, isFalse); | ||
| 13 | + | ||
| 14 | + await Wakelock.enable(); | ||
| 15 | + expect(await Wakelock.enabled, isTrue); | ||
| 16 | + await Wakelock.disable(); | ||
| 17 | + expect(await Wakelock.enabled, isFalse); | ||
| 18 | + }); | ||
| 19 | + | ||
| 20 | + testWidgets('toggling wakelock', (WidgetTester tester) async { | ||
| 21 | + await Wakelock.toggle(enable: true); | ||
| 22 | + expect(await Wakelock.enabled, isTrue); | ||
| 23 | + await Wakelock.toggle(enable: false); | ||
| 24 | + expect(await Wakelock.enabled, isFalse); | ||
| 25 | + }); | ||
| 26 | +} |
wakelock/example/ios/.gitignore
0 → 100644
| 1 | +*.mode1v3 | ||
| 2 | +*.mode2v3 | ||
| 3 | +*.moved-aside | ||
| 4 | +*.pbxuser | ||
| 5 | +*.perspectivev3 | ||
| 6 | +**/*sync/ | ||
| 7 | +.sconsign.dblite | ||
| 8 | +.tags* | ||
| 9 | +**/.vagrant/ | ||
| 10 | +**/DerivedData/ | ||
| 11 | +Icon? | ||
| 12 | +**/Pods/ | ||
| 13 | +**/.symlinks/ | ||
| 14 | +profile | ||
| 15 | +xcuserdata | ||
| 16 | +**/.generated/ | ||
| 17 | +Flutter/App.framework | ||
| 18 | +Flutter/Flutter.framework | ||
| 19 | +Flutter/Flutter.podspec | ||
| 20 | +Flutter/Generated.xcconfig | ||
| 21 | +Flutter/app.flx | ||
| 22 | +Flutter/app.zip | ||
| 23 | +Flutter/flutter_assets/ | ||
| 24 | +Flutter/flutter_export_environment.sh | ||
| 25 | +ServiceDefinitions.json | ||
| 26 | +Runner/GeneratedPluginRegistrant.* | ||
| 27 | + | ||
| 28 | +# Exceptions to above rules. | ||
| 29 | +!default.mode1v3 | ||
| 30 | +!default.mode2v3 | ||
| 31 | +!default.pbxuser | ||
| 32 | +!default.perspectivev3 |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | +<plist version="1.0"> | ||
| 4 | +<dict> | ||
| 5 | + <key>CFBundleDevelopmentRegion</key> | ||
| 6 | + <string>$(DEVELOPMENT_LANGUAGE)</string> | ||
| 7 | + <key>CFBundleExecutable</key> | ||
| 8 | + <string>App</string> | ||
| 9 | + <key>CFBundleIdentifier</key> | ||
| 10 | + <string>io.flutter.flutter.app</string> | ||
| 11 | + <key>CFBundleInfoDictionaryVersion</key> | ||
| 12 | + <string>6.0</string> | ||
| 13 | + <key>CFBundleName</key> | ||
| 14 | + <string>App</string> | ||
| 15 | + <key>CFBundlePackageType</key> | ||
| 16 | + <string>FMWK</string> | ||
| 17 | + <key>CFBundleShortVersionString</key> | ||
| 18 | + <string>1.0</string> | ||
| 19 | + <key>CFBundleSignature</key> | ||
| 20 | + <string>????</string> | ||
| 21 | + <key>CFBundleVersion</key> | ||
| 22 | + <string>1.0</string> | ||
| 23 | + <key>MinimumOSVersion</key> | ||
| 24 | + <string>9.0</string> | ||
| 25 | +</dict> | ||
| 26 | +</plist> |
wakelock/example/ios/Flutter/Debug.xcconfig
0 → 100644
wakelock/example/ios/Podfile
0 → 100644
| 1 | +# Uncomment this line to define a global platform for your project | ||
| 2 | +# platform :ios, '9.0' | ||
| 3 | + | ||
| 4 | +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. | ||
| 5 | +ENV['COCOAPODS_DISABLE_STATS'] = 'true' | ||
| 6 | + | ||
| 7 | +project 'Runner', { | ||
| 8 | + 'Debug' => :debug, | ||
| 9 | + 'Profile' => :release, | ||
| 10 | + 'Release' => :release, | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +def flutter_root | ||
| 14 | + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) | ||
| 15 | + unless File.exist?(generated_xcode_build_settings_path) | ||
| 16 | + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" | ||
| 17 | + end | ||
| 18 | + | ||
| 19 | + File.foreach(generated_xcode_build_settings_path) do |line| | ||
| 20 | + matches = line.match(/FLUTTER_ROOT\=(.*)/) | ||
| 21 | + return matches[1].strip if matches | ||
| 22 | + end | ||
| 23 | + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" | ||
| 24 | +end | ||
| 25 | + | ||
| 26 | +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) | ||
| 27 | + | ||
| 28 | +flutter_ios_podfile_setup | ||
| 29 | + | ||
| 30 | +target 'Runner' do | ||
| 31 | + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) | ||
| 32 | +end | ||
| 33 | + | ||
| 34 | +post_install do |installer| | ||
| 35 | + installer.pods_project.targets.each do |target| | ||
| 36 | + flutter_additional_ios_build_settings(target) | ||
| 37 | + end | ||
| 38 | +end |
wakelock/example/ios/Podfile.lock
0 → 100644
| 1 | +PODS: | ||
| 2 | + - Flutter (1.0.0) | ||
| 3 | + - integration_test (0.0.1): | ||
| 4 | + - Flutter | ||
| 5 | + - wakelock (0.0.1): | ||
| 6 | + - Flutter | ||
| 7 | + | ||
| 8 | +DEPENDENCIES: | ||
| 9 | + - Flutter (from `Flutter`) | ||
| 10 | + - integration_test (from `.symlinks/plugins/integration_test/ios`) | ||
| 11 | + - wakelock (from `.symlinks/plugins/wakelock/ios`) | ||
| 12 | + | ||
| 13 | +EXTERNAL SOURCES: | ||
| 14 | + Flutter: | ||
| 15 | + :path: Flutter | ||
| 16 | + integration_test: | ||
| 17 | + :path: ".symlinks/plugins/integration_test/ios" | ||
| 18 | + wakelock: | ||
| 19 | + :path: ".symlinks/plugins/wakelock/ios" | ||
| 20 | + | ||
| 21 | +SPEC CHECKSUMS: | ||
| 22 | + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec | ||
| 23 | + integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e | ||
| 24 | + wakelock: bfc7955c418d0db797614075aabbc58a39ab5107 | ||
| 25 | + | ||
| 26 | +PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d | ||
| 27 | + | ||
| 28 | +COCOAPODS: 1.9.3 |
| 1 | +// !$*UTF8*$! | ||
| 2 | +{ | ||
| 3 | + archiveVersion = 1; | ||
| 4 | + classes = { | ||
| 5 | + }; | ||
| 6 | + objectVersion = 46; | ||
| 7 | + objects = { | ||
| 8 | + | ||
| 9 | +/* Begin PBXBuildFile section */ | ||
| 10 | + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; | ||
| 11 | + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; | ||
| 12 | + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; | ||
| 13 | + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; | ||
| 14 | + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; | ||
| 15 | + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; | ||
| 16 | + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; | ||
| 17 | + A6847046D3B647529A66EE97 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 320D1841761F9CD1E849A1F0 /* libPods-Runner.a */; }; | ||
| 18 | +/* End PBXBuildFile section */ | ||
| 19 | + | ||
| 20 | +/* Begin PBXCopyFilesBuildPhase section */ | ||
| 21 | + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { | ||
| 22 | + isa = PBXCopyFilesBuildPhase; | ||
| 23 | + buildActionMask = 2147483647; | ||
| 24 | + dstPath = ""; | ||
| 25 | + dstSubfolderSpec = 10; | ||
| 26 | + files = ( | ||
| 27 | + ); | ||
| 28 | + name = "Embed Frameworks"; | ||
| 29 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 30 | + }; | ||
| 31 | +/* End PBXCopyFilesBuildPhase section */ | ||
| 32 | + | ||
| 33 | +/* Begin PBXFileReference section */ | ||
| 34 | + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; | ||
| 35 | + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; }; | ||
| 36 | + 2111AD0340E57F623E74EE98 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; }; | ||
| 37 | + 320D1841761F9CD1E849A1F0 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 38 | + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; }; | ||
| 39 | + 6937DE1C1E231CE26C21EB6B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; }; | ||
| 40 | + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; }; | ||
| 41 | + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; | ||
| 42 | + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; | ||
| 43 | + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; }; | ||
| 44 | + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; }; | ||
| 45 | + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| 46 | + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; | ||
| 47 | + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; }; | ||
| 48 | + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; | ||
| 49 | + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; | ||
| 50 | + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; | ||
| 51 | + F6CC63182AFEEC23EAC5C95F /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; }; | ||
| 52 | +/* End PBXFileReference section */ | ||
| 53 | + | ||
| 54 | +/* Begin PBXFrameworksBuildPhase section */ | ||
| 55 | + 97C146EB1CF9000F007C117D /* Frameworks */ = { | ||
| 56 | + isa = PBXFrameworksBuildPhase; | ||
| 57 | + buildActionMask = 2147483647; | ||
| 58 | + files = ( | ||
| 59 | + A6847046D3B647529A66EE97 /* libPods-Runner.a in Frameworks */, | ||
| 60 | + ); | ||
| 61 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 62 | + }; | ||
| 63 | +/* End PBXFrameworksBuildPhase section */ | ||
| 64 | + | ||
| 65 | +/* Begin PBXGroup section */ | ||
| 66 | + 356EF92E5865B0B43E707F28 /* Frameworks */ = { | ||
| 67 | + isa = PBXGroup; | ||
| 68 | + children = ( | ||
| 69 | + 320D1841761F9CD1E849A1F0 /* libPods-Runner.a */, | ||
| 70 | + ); | ||
| 71 | + name = Frameworks; | ||
| 72 | + sourceTree = "<group>"; | ||
| 73 | + }; | ||
| 74 | + 7865595A245EC8291D1003FA /* Pods */ = { | ||
| 75 | + isa = PBXGroup; | ||
| 76 | + children = ( | ||
| 77 | + F6CC63182AFEEC23EAC5C95F /* Pods-Runner.debug.xcconfig */, | ||
| 78 | + 2111AD0340E57F623E74EE98 /* Pods-Runner.release.xcconfig */, | ||
| 79 | + 6937DE1C1E231CE26C21EB6B /* Pods-Runner.profile.xcconfig */, | ||
| 80 | + ); | ||
| 81 | + name = Pods; | ||
| 82 | + path = Pods; | ||
| 83 | + sourceTree = "<group>"; | ||
| 84 | + }; | ||
| 85 | + 9740EEB11CF90186004384FC /* Flutter */ = { | ||
| 86 | + isa = PBXGroup; | ||
| 87 | + children = ( | ||
| 88 | + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, | ||
| 89 | + 9740EEB21CF90195004384FC /* Debug.xcconfig */, | ||
| 90 | + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, | ||
| 91 | + 9740EEB31CF90195004384FC /* Generated.xcconfig */, | ||
| 92 | + ); | ||
| 93 | + name = Flutter; | ||
| 94 | + sourceTree = "<group>"; | ||
| 95 | + }; | ||
| 96 | + 97C146E51CF9000F007C117D = { | ||
| 97 | + isa = PBXGroup; | ||
| 98 | + children = ( | ||
| 99 | + 9740EEB11CF90186004384FC /* Flutter */, | ||
| 100 | + 97C146F01CF9000F007C117D /* Runner */, | ||
| 101 | + 97C146EF1CF9000F007C117D /* Products */, | ||
| 102 | + 7865595A245EC8291D1003FA /* Pods */, | ||
| 103 | + 356EF92E5865B0B43E707F28 /* Frameworks */, | ||
| 104 | + ); | ||
| 105 | + sourceTree = "<group>"; | ||
| 106 | + }; | ||
| 107 | + 97C146EF1CF9000F007C117D /* Products */ = { | ||
| 108 | + isa = PBXGroup; | ||
| 109 | + children = ( | ||
| 110 | + 97C146EE1CF9000F007C117D /* Runner.app */, | ||
| 111 | + ); | ||
| 112 | + name = Products; | ||
| 113 | + sourceTree = "<group>"; | ||
| 114 | + }; | ||
| 115 | + 97C146F01CF9000F007C117D /* Runner */ = { | ||
| 116 | + isa = PBXGroup; | ||
| 117 | + children = ( | ||
| 118 | + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, | ||
| 119 | + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, | ||
| 120 | + 97C146FA1CF9000F007C117D /* Main.storyboard */, | ||
| 121 | + 97C146FD1CF9000F007C117D /* Assets.xcassets */, | ||
| 122 | + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, | ||
| 123 | + 97C147021CF9000F007C117D /* Info.plist */, | ||
| 124 | + 97C146F11CF9000F007C117D /* Supporting Files */, | ||
| 125 | + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, | ||
| 126 | + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, | ||
| 127 | + ); | ||
| 128 | + path = Runner; | ||
| 129 | + sourceTree = "<group>"; | ||
| 130 | + }; | ||
| 131 | + 97C146F11CF9000F007C117D /* Supporting Files */ = { | ||
| 132 | + isa = PBXGroup; | ||
| 133 | + children = ( | ||
| 134 | + 97C146F21CF9000F007C117D /* main.m */, | ||
| 135 | + ); | ||
| 136 | + name = "Supporting Files"; | ||
| 137 | + sourceTree = "<group>"; | ||
| 138 | + }; | ||
| 139 | +/* End PBXGroup section */ | ||
| 140 | + | ||
| 141 | +/* Begin PBXNativeTarget section */ | ||
| 142 | + 97C146ED1CF9000F007C117D /* Runner */ = { | ||
| 143 | + isa = PBXNativeTarget; | ||
| 144 | + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; | ||
| 145 | + buildPhases = ( | ||
| 146 | + 112EA101BE908B08DE569906 /* [CP] Check Pods Manifest.lock */, | ||
| 147 | + 9740EEB61CF901F6004384FC /* Run Script */, | ||
| 148 | + 97C146EA1CF9000F007C117D /* Sources */, | ||
| 149 | + 97C146EB1CF9000F007C117D /* Frameworks */, | ||
| 150 | + 97C146EC1CF9000F007C117D /* Resources */, | ||
| 151 | + 9705A1C41CF9048500538489 /* Embed Frameworks */, | ||
| 152 | + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, | ||
| 153 | + FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */, | ||
| 154 | + ); | ||
| 155 | + buildRules = ( | ||
| 156 | + ); | ||
| 157 | + dependencies = ( | ||
| 158 | + ); | ||
| 159 | + name = Runner; | ||
| 160 | + productName = Runner; | ||
| 161 | + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; | ||
| 162 | + productType = "com.apple.product-type.application"; | ||
| 163 | + }; | ||
| 164 | +/* End PBXNativeTarget section */ | ||
| 165 | + | ||
| 166 | +/* Begin PBXProject section */ | ||
| 167 | + 97C146E61CF9000F007C117D /* Project object */ = { | ||
| 168 | + isa = PBXProject; | ||
| 169 | + attributes = { | ||
| 170 | + LastUpgradeCheck = 1020; | ||
| 171 | + ORGANIZATIONNAME = ""; | ||
| 172 | + TargetAttributes = { | ||
| 173 | + 97C146ED1CF9000F007C117D = { | ||
| 174 | + CreatedOnToolsVersion = 7.3.1; | ||
| 175 | + }; | ||
| 176 | + }; | ||
| 177 | + }; | ||
| 178 | + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; | ||
| 179 | + compatibilityVersion = "Xcode 9.3"; | ||
| 180 | + developmentRegion = en; | ||
| 181 | + hasScannedForEncodings = 0; | ||
| 182 | + knownRegions = ( | ||
| 183 | + en, | ||
| 184 | + Base, | ||
| 185 | + ); | ||
| 186 | + mainGroup = 97C146E51CF9000F007C117D; | ||
| 187 | + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; | ||
| 188 | + projectDirPath = ""; | ||
| 189 | + projectRoot = ""; | ||
| 190 | + targets = ( | ||
| 191 | + 97C146ED1CF9000F007C117D /* Runner */, | ||
| 192 | + ); | ||
| 193 | + }; | ||
| 194 | +/* End PBXProject section */ | ||
| 195 | + | ||
| 196 | +/* Begin PBXResourcesBuildPhase section */ | ||
| 197 | + 97C146EC1CF9000F007C117D /* Resources */ = { | ||
| 198 | + isa = PBXResourcesBuildPhase; | ||
| 199 | + buildActionMask = 2147483647; | ||
| 200 | + files = ( | ||
| 201 | + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, | ||
| 202 | + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, | ||
| 203 | + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, | ||
| 204 | + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, | ||
| 205 | + ); | ||
| 206 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 207 | + }; | ||
| 208 | +/* End PBXResourcesBuildPhase section */ | ||
| 209 | + | ||
| 210 | +/* Begin PBXShellScriptBuildPhase section */ | ||
| 211 | + 112EA101BE908B08DE569906 /* [CP] Check Pods Manifest.lock */ = { | ||
| 212 | + isa = PBXShellScriptBuildPhase; | ||
| 213 | + buildActionMask = 2147483647; | ||
| 214 | + files = ( | ||
| 215 | + ); | ||
| 216 | + inputFileListPaths = ( | ||
| 217 | + ); | ||
| 218 | + inputPaths = ( | ||
| 219 | + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", | ||
| 220 | + "${PODS_ROOT}/Manifest.lock", | ||
| 221 | + ); | ||
| 222 | + name = "[CP] Check Pods Manifest.lock"; | ||
| 223 | + outputFileListPaths = ( | ||
| 224 | + ); | ||
| 225 | + outputPaths = ( | ||
| 226 | + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", | ||
| 227 | + ); | ||
| 228 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 229 | + shellPath = /bin/sh; | ||
| 230 | + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; | ||
| 231 | + showEnvVarsInLog = 0; | ||
| 232 | + }; | ||
| 233 | + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { | ||
| 234 | + isa = PBXShellScriptBuildPhase; | ||
| 235 | + buildActionMask = 2147483647; | ||
| 236 | + files = ( | ||
| 237 | + ); | ||
| 238 | + inputPaths = ( | ||
| 239 | + ); | ||
| 240 | + name = "Thin Binary"; | ||
| 241 | + outputPaths = ( | ||
| 242 | + ); | ||
| 243 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 244 | + shellPath = /bin/sh; | ||
| 245 | + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; | ||
| 246 | + }; | ||
| 247 | + 9740EEB61CF901F6004384FC /* Run Script */ = { | ||
| 248 | + isa = PBXShellScriptBuildPhase; | ||
| 249 | + buildActionMask = 2147483647; | ||
| 250 | + files = ( | ||
| 251 | + ); | ||
| 252 | + inputPaths = ( | ||
| 253 | + ); | ||
| 254 | + name = "Run Script"; | ||
| 255 | + outputPaths = ( | ||
| 256 | + ); | ||
| 257 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 258 | + shellPath = /bin/sh; | ||
| 259 | + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; | ||
| 260 | + }; | ||
| 261 | + FAD6D21B222DFE9FB43C310E /* [CP] Embed Pods Frameworks */ = { | ||
| 262 | + isa = PBXShellScriptBuildPhase; | ||
| 263 | + buildActionMask = 2147483647; | ||
| 264 | + files = ( | ||
| 265 | + ); | ||
| 266 | + inputPaths = ( | ||
| 267 | + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", | ||
| 268 | + "${PODS_ROOT}/../Flutter/Flutter.framework", | ||
| 269 | + ); | ||
| 270 | + name = "[CP] Embed Pods Frameworks"; | ||
| 271 | + outputPaths = ( | ||
| 272 | + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", | ||
| 273 | + ); | ||
| 274 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 275 | + shellPath = /bin/sh; | ||
| 276 | + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; | ||
| 277 | + showEnvVarsInLog = 0; | ||
| 278 | + }; | ||
| 279 | +/* End PBXShellScriptBuildPhase section */ | ||
| 280 | + | ||
| 281 | +/* Begin PBXSourcesBuildPhase section */ | ||
| 282 | + 97C146EA1CF9000F007C117D /* Sources */ = { | ||
| 283 | + isa = PBXSourcesBuildPhase; | ||
| 284 | + buildActionMask = 2147483647; | ||
| 285 | + files = ( | ||
| 286 | + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, | ||
| 287 | + 97C146F31CF9000F007C117D /* main.m in Sources */, | ||
| 288 | + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, | ||
| 289 | + ); | ||
| 290 | + runOnlyForDeploymentPostprocessing = 0; | ||
| 291 | + }; | ||
| 292 | +/* End PBXSourcesBuildPhase section */ | ||
| 293 | + | ||
| 294 | +/* Begin PBXVariantGroup section */ | ||
| 295 | + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { | ||
| 296 | + isa = PBXVariantGroup; | ||
| 297 | + children = ( | ||
| 298 | + 97C146FB1CF9000F007C117D /* Base */, | ||
| 299 | + ); | ||
| 300 | + name = Main.storyboard; | ||
| 301 | + sourceTree = "<group>"; | ||
| 302 | + }; | ||
| 303 | + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { | ||
| 304 | + isa = PBXVariantGroup; | ||
| 305 | + children = ( | ||
| 306 | + 97C147001CF9000F007C117D /* Base */, | ||
| 307 | + ); | ||
| 308 | + name = LaunchScreen.storyboard; | ||
| 309 | + sourceTree = "<group>"; | ||
| 310 | + }; | ||
| 311 | +/* End PBXVariantGroup section */ | ||
| 312 | + | ||
| 313 | +/* Begin XCBuildConfiguration section */ | ||
| 314 | + 249021D3217E4FDB00AE95B9 /* Profile */ = { | ||
| 315 | + isa = XCBuildConfiguration; | ||
| 316 | + buildSettings = { | ||
| 317 | + ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 318 | + CLANG_ANALYZER_NONNULL = YES; | ||
| 319 | + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
| 320 | + CLANG_CXX_LIBRARY = "libc++"; | ||
| 321 | + CLANG_ENABLE_MODULES = YES; | ||
| 322 | + CLANG_ENABLE_OBJC_ARC = YES; | ||
| 323 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 324 | + CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 325 | + CLANG_WARN_COMMA = YES; | ||
| 326 | + CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 327 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 328 | + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 329 | + CLANG_WARN_EMPTY_BODY = YES; | ||
| 330 | + CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 331 | + CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 332 | + CLANG_WARN_INT_CONVERSION = YES; | ||
| 333 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 334 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
| 335 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 336 | + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 337 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 338 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
| 339 | + CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 340 | + CLANG_WARN_UNREACHABLE_CODE = YES; | ||
| 341 | + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
| 342 | + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; | ||
| 343 | + COPY_PHASE_STRIP = NO; | ||
| 344 | + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
| 345 | + ENABLE_NS_ASSERTIONS = NO; | ||
| 346 | + ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 347 | + GCC_C_LANGUAGE_STANDARD = gnu99; | ||
| 348 | + GCC_NO_COMMON_BLOCKS = YES; | ||
| 349 | + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 350 | + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 351 | + GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
| 352 | + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 353 | + GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 354 | + GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 355 | + IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
| 356 | + MTL_ENABLE_DEBUG_INFO = NO; | ||
| 357 | + SDKROOT = iphoneos; | ||
| 358 | + SUPPORTED_PLATFORMS = iphoneos; | ||
| 359 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 360 | + VALIDATE_PRODUCT = YES; | ||
| 361 | + }; | ||
| 362 | + name = Profile; | ||
| 363 | + }; | ||
| 364 | + 249021D4217E4FDB00AE95B9 /* Profile */ = { | ||
| 365 | + isa = XCBuildConfiguration; | ||
| 366 | + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; | ||
| 367 | + buildSettings = { | ||
| 368 | + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 369 | + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||
| 370 | + ENABLE_BITCODE = NO; | ||
| 371 | + FRAMEWORK_SEARCH_PATHS = ( | ||
| 372 | + "$(inherited)", | ||
| 373 | + "$(PROJECT_DIR)/Flutter", | ||
| 374 | + ); | ||
| 375 | + INFOPLIST_FILE = Runner/Info.plist; | ||
| 376 | + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
| 377 | + LIBRARY_SEARCH_PATHS = ( | ||
| 378 | + "$(inherited)", | ||
| 379 | + "$(PROJECT_DIR)/Flutter", | ||
| 380 | + ); | ||
| 381 | + PRODUCT_BUNDLE_IDENTIFIER = creativemaybeno.wakelockExample; | ||
| 382 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 383 | + VERSIONING_SYSTEM = "apple-generic"; | ||
| 384 | + }; | ||
| 385 | + name = Profile; | ||
| 386 | + }; | ||
| 387 | + 97C147031CF9000F007C117D /* Debug */ = { | ||
| 388 | + isa = XCBuildConfiguration; | ||
| 389 | + buildSettings = { | ||
| 390 | + ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 391 | + CLANG_ANALYZER_NONNULL = YES; | ||
| 392 | + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
| 393 | + CLANG_CXX_LIBRARY = "libc++"; | ||
| 394 | + CLANG_ENABLE_MODULES = YES; | ||
| 395 | + CLANG_ENABLE_OBJC_ARC = YES; | ||
| 396 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 397 | + CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 398 | + CLANG_WARN_COMMA = YES; | ||
| 399 | + CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 400 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 401 | + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 402 | + CLANG_WARN_EMPTY_BODY = YES; | ||
| 403 | + CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 404 | + CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 405 | + CLANG_WARN_INT_CONVERSION = YES; | ||
| 406 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 407 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
| 408 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 409 | + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 410 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 411 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
| 412 | + CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 413 | + CLANG_WARN_UNREACHABLE_CODE = YES; | ||
| 414 | + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
| 415 | + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; | ||
| 416 | + COPY_PHASE_STRIP = NO; | ||
| 417 | + DEBUG_INFORMATION_FORMAT = dwarf; | ||
| 418 | + ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 419 | + ENABLE_TESTABILITY = YES; | ||
| 420 | + GCC_C_LANGUAGE_STANDARD = gnu99; | ||
| 421 | + GCC_DYNAMIC_NO_PIC = NO; | ||
| 422 | + GCC_NO_COMMON_BLOCKS = YES; | ||
| 423 | + GCC_OPTIMIZATION_LEVEL = 0; | ||
| 424 | + GCC_PREPROCESSOR_DEFINITIONS = ( | ||
| 425 | + "DEBUG=1", | ||
| 426 | + "$(inherited)", | ||
| 427 | + ); | ||
| 428 | + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 429 | + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 430 | + GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
| 431 | + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 432 | + GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 433 | + GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 434 | + IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
| 435 | + MTL_ENABLE_DEBUG_INFO = YES; | ||
| 436 | + ONLY_ACTIVE_ARCH = YES; | ||
| 437 | + SDKROOT = iphoneos; | ||
| 438 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 439 | + }; | ||
| 440 | + name = Debug; | ||
| 441 | + }; | ||
| 442 | + 97C147041CF9000F007C117D /* Release */ = { | ||
| 443 | + isa = XCBuildConfiguration; | ||
| 444 | + buildSettings = { | ||
| 445 | + ALWAYS_SEARCH_USER_PATHS = NO; | ||
| 446 | + CLANG_ANALYZER_NONNULL = YES; | ||
| 447 | + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; | ||
| 448 | + CLANG_CXX_LIBRARY = "libc++"; | ||
| 449 | + CLANG_ENABLE_MODULES = YES; | ||
| 450 | + CLANG_ENABLE_OBJC_ARC = YES; | ||
| 451 | + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; | ||
| 452 | + CLANG_WARN_BOOL_CONVERSION = YES; | ||
| 453 | + CLANG_WARN_COMMA = YES; | ||
| 454 | + CLANG_WARN_CONSTANT_CONVERSION = YES; | ||
| 455 | + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; | ||
| 456 | + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; | ||
| 457 | + CLANG_WARN_EMPTY_BODY = YES; | ||
| 458 | + CLANG_WARN_ENUM_CONVERSION = YES; | ||
| 459 | + CLANG_WARN_INFINITE_RECURSION = YES; | ||
| 460 | + CLANG_WARN_INT_CONVERSION = YES; | ||
| 461 | + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; | ||
| 462 | + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; | ||
| 463 | + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; | ||
| 464 | + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; | ||
| 465 | + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; | ||
| 466 | + CLANG_WARN_STRICT_PROTOTYPES = YES; | ||
| 467 | + CLANG_WARN_SUSPICIOUS_MOVE = YES; | ||
| 468 | + CLANG_WARN_UNREACHABLE_CODE = YES; | ||
| 469 | + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; | ||
| 470 | + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; | ||
| 471 | + COPY_PHASE_STRIP = NO; | ||
| 472 | + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; | ||
| 473 | + ENABLE_NS_ASSERTIONS = NO; | ||
| 474 | + ENABLE_STRICT_OBJC_MSGSEND = YES; | ||
| 475 | + GCC_C_LANGUAGE_STANDARD = gnu99; | ||
| 476 | + GCC_NO_COMMON_BLOCKS = YES; | ||
| 477 | + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; | ||
| 478 | + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; | ||
| 479 | + GCC_WARN_UNDECLARED_SELECTOR = YES; | ||
| 480 | + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | ||
| 481 | + GCC_WARN_UNUSED_FUNCTION = YES; | ||
| 482 | + GCC_WARN_UNUSED_VARIABLE = YES; | ||
| 483 | + IPHONEOS_DEPLOYMENT_TARGET = 9.0; | ||
| 484 | + MTL_ENABLE_DEBUG_INFO = NO; | ||
| 485 | + SDKROOT = iphoneos; | ||
| 486 | + SUPPORTED_PLATFORMS = iphoneos; | ||
| 487 | + TARGETED_DEVICE_FAMILY = "1,2"; | ||
| 488 | + VALIDATE_PRODUCT = YES; | ||
| 489 | + }; | ||
| 490 | + name = Release; | ||
| 491 | + }; | ||
| 492 | + 97C147061CF9000F007C117D /* Debug */ = { | ||
| 493 | + isa = XCBuildConfiguration; | ||
| 494 | + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; | ||
| 495 | + buildSettings = { | ||
| 496 | + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 497 | + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||
| 498 | + ENABLE_BITCODE = NO; | ||
| 499 | + FRAMEWORK_SEARCH_PATHS = ( | ||
| 500 | + "$(inherited)", | ||
| 501 | + "$(PROJECT_DIR)/Flutter", | ||
| 502 | + ); | ||
| 503 | + INFOPLIST_FILE = Runner/Info.plist; | ||
| 504 | + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
| 505 | + LIBRARY_SEARCH_PATHS = ( | ||
| 506 | + "$(inherited)", | ||
| 507 | + "$(PROJECT_DIR)/Flutter", | ||
| 508 | + ); | ||
| 509 | + PRODUCT_BUNDLE_IDENTIFIER = creativemaybeno.wakelockExample; | ||
| 510 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 511 | + VERSIONING_SYSTEM = "apple-generic"; | ||
| 512 | + }; | ||
| 513 | + name = Debug; | ||
| 514 | + }; | ||
| 515 | + 97C147071CF9000F007C117D /* Release */ = { | ||
| 516 | + isa = XCBuildConfiguration; | ||
| 517 | + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; | ||
| 518 | + buildSettings = { | ||
| 519 | + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| 520 | + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; | ||
| 521 | + ENABLE_BITCODE = NO; | ||
| 522 | + FRAMEWORK_SEARCH_PATHS = ( | ||
| 523 | + "$(inherited)", | ||
| 524 | + "$(PROJECT_DIR)/Flutter", | ||
| 525 | + ); | ||
| 526 | + INFOPLIST_FILE = Runner/Info.plist; | ||
| 527 | + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; | ||
| 528 | + LIBRARY_SEARCH_PATHS = ( | ||
| 529 | + "$(inherited)", | ||
| 530 | + "$(PROJECT_DIR)/Flutter", | ||
| 531 | + ); | ||
| 532 | + PRODUCT_BUNDLE_IDENTIFIER = creativemaybeno.wakelockExample; | ||
| 533 | + PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| 534 | + VERSIONING_SYSTEM = "apple-generic"; | ||
| 535 | + }; | ||
| 536 | + name = Release; | ||
| 537 | + }; | ||
| 538 | +/* End XCBuildConfiguration section */ | ||
| 539 | + | ||
| 540 | +/* Begin XCConfigurationList section */ | ||
| 541 | + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { | ||
| 542 | + isa = XCConfigurationList; | ||
| 543 | + buildConfigurations = ( | ||
| 544 | + 97C147031CF9000F007C117D /* Debug */, | ||
| 545 | + 97C147041CF9000F007C117D /* Release */, | ||
| 546 | + 249021D3217E4FDB00AE95B9 /* Profile */, | ||
| 547 | + ); | ||
| 548 | + defaultConfigurationIsVisible = 0; | ||
| 549 | + defaultConfigurationName = Release; | ||
| 550 | + }; | ||
| 551 | + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { | ||
| 552 | + isa = XCConfigurationList; | ||
| 553 | + buildConfigurations = ( | ||
| 554 | + 97C147061CF9000F007C117D /* Debug */, | ||
| 555 | + 97C147071CF9000F007C117D /* Release */, | ||
| 556 | + 249021D4217E4FDB00AE95B9 /* Profile */, | ||
| 557 | + ); | ||
| 558 | + defaultConfigurationIsVisible = 0; | ||
| 559 | + defaultConfigurationName = Release; | ||
| 560 | + }; | ||
| 561 | +/* End XCConfigurationList section */ | ||
| 562 | + }; | ||
| 563 | + rootObject = 97C146E61CF9000F007C117D /* Project object */; | ||
| 564 | +} |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<Scheme | ||
| 3 | + LastUpgradeVersion = "1020" | ||
| 4 | + version = "1.3"> | ||
| 5 | + <BuildAction | ||
| 6 | + parallelizeBuildables = "YES" | ||
| 7 | + buildImplicitDependencies = "YES"> | ||
| 8 | + <BuildActionEntries> | ||
| 9 | + <BuildActionEntry | ||
| 10 | + buildForTesting = "YES" | ||
| 11 | + buildForRunning = "YES" | ||
| 12 | + buildForProfiling = "YES" | ||
| 13 | + buildForArchiving = "YES" | ||
| 14 | + buildForAnalyzing = "YES"> | ||
| 15 | + <BuildableReference | ||
| 16 | + BuildableIdentifier = "primary" | ||
| 17 | + BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
| 18 | + BuildableName = "Runner.app" | ||
| 19 | + BlueprintName = "Runner" | ||
| 20 | + ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 21 | + </BuildableReference> | ||
| 22 | + </BuildActionEntry> | ||
| 23 | + </BuildActionEntries> | ||
| 24 | + </BuildAction> | ||
| 25 | + <TestAction | ||
| 26 | + buildConfiguration = "Debug" | ||
| 27 | + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| 28 | + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| 29 | + shouldUseLaunchSchemeArgsEnv = "YES"> | ||
| 30 | + <Testables> | ||
| 31 | + </Testables> | ||
| 32 | + <MacroExpansion> | ||
| 33 | + <BuildableReference | ||
| 34 | + BuildableIdentifier = "primary" | ||
| 35 | + BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
| 36 | + BuildableName = "Runner.app" | ||
| 37 | + BlueprintName = "Runner" | ||
| 38 | + ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 39 | + </BuildableReference> | ||
| 40 | + </MacroExpansion> | ||
| 41 | + <AdditionalOptions> | ||
| 42 | + </AdditionalOptions> | ||
| 43 | + </TestAction> | ||
| 44 | + <LaunchAction | ||
| 45 | + buildConfiguration = "Debug" | ||
| 46 | + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
| 47 | + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
| 48 | + launchStyle = "0" | ||
| 49 | + useCustomWorkingDirectory = "NO" | ||
| 50 | + ignoresPersistentStateOnLaunch = "NO" | ||
| 51 | + debugDocumentVersioning = "YES" | ||
| 52 | + debugServiceExtension = "internal" | ||
| 53 | + allowLocationSimulation = "YES"> | ||
| 54 | + <BuildableProductRunnable | ||
| 55 | + runnableDebuggingMode = "0"> | ||
| 56 | + <BuildableReference | ||
| 57 | + BuildableIdentifier = "primary" | ||
| 58 | + BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
| 59 | + BuildableName = "Runner.app" | ||
| 60 | + BlueprintName = "Runner" | ||
| 61 | + ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 62 | + </BuildableReference> | ||
| 63 | + </BuildableProductRunnable> | ||
| 64 | + <AdditionalOptions> | ||
| 65 | + </AdditionalOptions> | ||
| 66 | + </LaunchAction> | ||
| 67 | + <ProfileAction | ||
| 68 | + buildConfiguration = "Profile" | ||
| 69 | + shouldUseLaunchSchemeArgsEnv = "YES" | ||
| 70 | + savedToolIdentifier = "" | ||
| 71 | + useCustomWorkingDirectory = "NO" | ||
| 72 | + debugDocumentVersioning = "YES"> | ||
| 73 | + <BuildableProductRunnable | ||
| 74 | + runnableDebuggingMode = "0"> | ||
| 75 | + <BuildableReference | ||
| 76 | + BuildableIdentifier = "primary" | ||
| 77 | + BlueprintIdentifier = "97C146ED1CF9000F007C117D" | ||
| 78 | + BuildableName = "Runner.app" | ||
| 79 | + BlueprintName = "Runner" | ||
| 80 | + ReferencedContainer = "container:Runner.xcodeproj"> | ||
| 81 | + </BuildableReference> | ||
| 82 | + </BuildableProductRunnable> | ||
| 83 | + </ProfileAction> | ||
| 84 | + <AnalyzeAction | ||
| 85 | + buildConfiguration = "Debug"> | ||
| 86 | + </AnalyzeAction> | ||
| 87 | + <ArchiveAction | ||
| 88 | + buildConfiguration = "Release" | ||
| 89 | + revealArchiveInOrganizer = "YES"> | ||
| 90 | + </ArchiveAction> | ||
| 91 | +</Scheme> |
wakelock/example/ios/Runner/AppDelegate.h
0 → 100644
wakelock/example/ios/Runner/AppDelegate.m
0 → 100644
| 1 | +#import "AppDelegate.h" | ||
| 2 | +#import "GeneratedPluginRegistrant.h" | ||
| 3 | + | ||
| 4 | +@implementation AppDelegate | ||
| 5 | + | ||
| 6 | +- (BOOL)application:(UIApplication *)application | ||
| 7 | + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
| 8 | + [GeneratedPluginRegistrant registerWithRegistry:self]; | ||
| 9 | + // Override point for customization after application launch. | ||
| 10 | + return [super application:application didFinishLaunchingWithOptions:launchOptions]; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +@end |
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "size" : "20x20", | ||
| 5 | + "idiom" : "iphone", | ||
| 6 | + "filename" : "Icon-App-20x20@2x.png", | ||
| 7 | + "scale" : "2x" | ||
| 8 | + }, | ||
| 9 | + { | ||
| 10 | + "size" : "20x20", | ||
| 11 | + "idiom" : "iphone", | ||
| 12 | + "filename" : "Icon-App-20x20@3x.png", | ||
| 13 | + "scale" : "3x" | ||
| 14 | + }, | ||
| 15 | + { | ||
| 16 | + "size" : "29x29", | ||
| 17 | + "idiom" : "iphone", | ||
| 18 | + "filename" : "Icon-App-29x29@1x.png", | ||
| 19 | + "scale" : "1x" | ||
| 20 | + }, | ||
| 21 | + { | ||
| 22 | + "size" : "29x29", | ||
| 23 | + "idiom" : "iphone", | ||
| 24 | + "filename" : "Icon-App-29x29@2x.png", | ||
| 25 | + "scale" : "2x" | ||
| 26 | + }, | ||
| 27 | + { | ||
| 28 | + "size" : "29x29", | ||
| 29 | + "idiom" : "iphone", | ||
| 30 | + "filename" : "Icon-App-29x29@3x.png", | ||
| 31 | + "scale" : "3x" | ||
| 32 | + }, | ||
| 33 | + { | ||
| 34 | + "size" : "40x40", | ||
| 35 | + "idiom" : "iphone", | ||
| 36 | + "filename" : "Icon-App-40x40@2x.png", | ||
| 37 | + "scale" : "2x" | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "size" : "40x40", | ||
| 41 | + "idiom" : "iphone", | ||
| 42 | + "filename" : "Icon-App-40x40@3x.png", | ||
| 43 | + "scale" : "3x" | ||
| 44 | + }, | ||
| 45 | + { | ||
| 46 | + "size" : "60x60", | ||
| 47 | + "idiom" : "iphone", | ||
| 48 | + "filename" : "Icon-App-60x60@2x.png", | ||
| 49 | + "scale" : "2x" | ||
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + "size" : "60x60", | ||
| 53 | + "idiom" : "iphone", | ||
| 54 | + "filename" : "Icon-App-60x60@3x.png", | ||
| 55 | + "scale" : "3x" | ||
| 56 | + }, | ||
| 57 | + { | ||
| 58 | + "size" : "20x20", | ||
| 59 | + "idiom" : "ipad", | ||
| 60 | + "filename" : "Icon-App-20x20@1x.png", | ||
| 61 | + "scale" : "1x" | ||
| 62 | + }, | ||
| 63 | + { | ||
| 64 | + "size" : "20x20", | ||
| 65 | + "idiom" : "ipad", | ||
| 66 | + "filename" : "Icon-App-20x20@2x.png", | ||
| 67 | + "scale" : "2x" | ||
| 68 | + }, | ||
| 69 | + { | ||
| 70 | + "size" : "29x29", | ||
| 71 | + "idiom" : "ipad", | ||
| 72 | + "filename" : "Icon-App-29x29@1x.png", | ||
| 73 | + "scale" : "1x" | ||
| 74 | + }, | ||
| 75 | + { | ||
| 76 | + "size" : "29x29", | ||
| 77 | + "idiom" : "ipad", | ||
| 78 | + "filename" : "Icon-App-29x29@2x.png", | ||
| 79 | + "scale" : "2x" | ||
| 80 | + }, | ||
| 81 | + { | ||
| 82 | + "size" : "40x40", | ||
| 83 | + "idiom" : "ipad", | ||
| 84 | + "filename" : "Icon-App-40x40@1x.png", | ||
| 85 | + "scale" : "1x" | ||
| 86 | + }, | ||
| 87 | + { | ||
| 88 | + "size" : "40x40", | ||
| 89 | + "idiom" : "ipad", | ||
| 90 | + "filename" : "Icon-App-40x40@2x.png", | ||
| 91 | + "scale" : "2x" | ||
| 92 | + }, | ||
| 93 | + { | ||
| 94 | + "size" : "76x76", | ||
| 95 | + "idiom" : "ipad", | ||
| 96 | + "filename" : "Icon-App-76x76@1x.png", | ||
| 97 | + "scale" : "1x" | ||
| 98 | + }, | ||
| 99 | + { | ||
| 100 | + "size" : "76x76", | ||
| 101 | + "idiom" : "ipad", | ||
| 102 | + "filename" : "Icon-App-76x76@2x.png", | ||
| 103 | + "scale" : "2x" | ||
| 104 | + }, | ||
| 105 | + { | ||
| 106 | + "size" : "83.5x83.5", | ||
| 107 | + "idiom" : "ipad", | ||
| 108 | + "filename" : "Icon-App-83.5x83.5@2x.png", | ||
| 109 | + "scale" : "2x" | ||
| 110 | + }, | ||
| 111 | + { | ||
| 112 | + "size" : "1024x1024", | ||
| 113 | + "idiom" : "ios-marketing", | ||
| 114 | + "filename" : "Icon-App-1024x1024@1x.png", | ||
| 115 | + "scale" : "1x" | ||
| 116 | + } | ||
| 117 | + ], | ||
| 118 | + "info" : { | ||
| 119 | + "version" : 1, | ||
| 120 | + "author" : "xcode" | ||
| 121 | + } | ||
| 122 | +} |
10.7 KB
564 Bytes
1.25 KB
1.55 KB
1 KB
1.68 KB
1.88 KB
1.25 KB
1.85 KB
2.6 KB
2.6 KB
3.74 KB
1.84 KB
3.22 KB
3.53 KB
| 1 | +{ | ||
| 2 | + "images" : [ | ||
| 3 | + { | ||
| 4 | + "idiom" : "universal", | ||
| 5 | + "filename" : "LaunchImage.png", | ||
| 6 | + "scale" : "1x" | ||
| 7 | + }, | ||
| 8 | + { | ||
| 9 | + "idiom" : "universal", | ||
| 10 | + "filename" : "LaunchImage@2x.png", | ||
| 11 | + "scale" : "2x" | ||
| 12 | + }, | ||
| 13 | + { | ||
| 14 | + "idiom" : "universal", | ||
| 15 | + "filename" : "LaunchImage@3x.png", | ||
| 16 | + "scale" : "3x" | ||
| 17 | + } | ||
| 18 | + ], | ||
| 19 | + "info" : { | ||
| 20 | + "version" : 1, | ||
| 21 | + "author" : "xcode" | ||
| 22 | + } | ||
| 23 | +} |
68 Bytes
68 Bytes
68 Bytes
| 1 | +# Launch Screen Assets | ||
| 2 | + | ||
| 3 | +You can customize the launch screen with your own desired assets by replacing the image files in this directory. | ||
| 4 | + | ||
| 5 | +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
| 3 | + <dependencies> | ||
| 4 | + <deployment identifier="iOS"/> | ||
| 5 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> | ||
| 6 | + </dependencies> | ||
| 7 | + <scenes> | ||
| 8 | + <!--View Controller--> | ||
| 9 | + <scene sceneID="EHf-IW-A2E"> | ||
| 10 | + <objects> | ||
| 11 | + <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
| 12 | + <layoutGuides> | ||
| 13 | + <viewControllerLayoutGuide type="top" id="Ydg-fD-yQy"/> | ||
| 14 | + <viewControllerLayoutGuide type="bottom" id="xbc-2k-c8Z"/> | ||
| 15 | + </layoutGuides> | ||
| 16 | + <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
| 17 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 18 | + <subviews> | ||
| 19 | + <imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"> | ||
| 20 | + </imageView> | ||
| 21 | + </subviews> | ||
| 22 | + <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | ||
| 23 | + <constraints> | ||
| 24 | + <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="1a2-6s-vTC"/> | ||
| 25 | + <constraint firstItem="YRO-k0-Ey4" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="4X2-HB-R7a"/> | ||
| 26 | + </constraints> | ||
| 27 | + </view> | ||
| 28 | + </viewController> | ||
| 29 | + <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
| 30 | + </objects> | ||
| 31 | + <point key="canvasLocation" x="53" y="375"/> | ||
| 32 | + </scene> | ||
| 33 | + </scenes> | ||
| 34 | + <resources> | ||
| 35 | + <image name="LaunchImage" width="168" height="185"/> | ||
| 36 | + </resources> | ||
| 37 | +</document> |
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> | ||
| 3 | + <dependencies> | ||
| 4 | + <deployment identifier="iOS"/> | ||
| 5 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/> | ||
| 6 | + </dependencies> | ||
| 7 | + <scenes> | ||
| 8 | + <!--Flutter View Controller--> | ||
| 9 | + <scene sceneID="tne-QT-ifu"> | ||
| 10 | + <objects> | ||
| 11 | + <viewController id="BYZ-38-t0r" customClass="FlutterViewController" sceneMemberID="viewController"> | ||
| 12 | + <layoutGuides> | ||
| 13 | + <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/> | ||
| 14 | + <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/> | ||
| 15 | + </layoutGuides> | ||
| 16 | + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> | ||
| 17 | + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> | ||
| 18 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| 19 | + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> | ||
| 20 | + </view> | ||
| 21 | + </viewController> | ||
| 22 | + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/> | ||
| 23 | + </objects> | ||
| 24 | + </scene> | ||
| 25 | + </scenes> | ||
| 26 | +</document> |
wakelock/example/ios/Runner/Info.plist
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| 3 | +<plist version="1.0"> | ||
| 4 | +<dict> | ||
| 5 | + <key>CFBundleDevelopmentRegion</key> | ||
| 6 | + <string>$(DEVELOPMENT_LANGUAGE)</string> | ||
| 7 | + <key>CFBundleExecutable</key> | ||
| 8 | + <string>$(EXECUTABLE_NAME)</string> | ||
| 9 | + <key>CFBundleIdentifier</key> | ||
| 10 | + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
| 11 | + <key>CFBundleInfoDictionaryVersion</key> | ||
| 12 | + <string>6.0</string> | ||
| 13 | + <key>CFBundleName</key> | ||
| 14 | + <string>wakelock_example</string> | ||
| 15 | + <key>CFBundlePackageType</key> | ||
| 16 | + <string>APPL</string> | ||
| 17 | + <key>CFBundleShortVersionString</key> | ||
| 18 | + <string>$(FLUTTER_BUILD_NAME)</string> | ||
| 19 | + <key>CFBundleSignature</key> | ||
| 20 | + <string>????</string> | ||
| 21 | + <key>CFBundleVersion</key> | ||
| 22 | + <string>$(FLUTTER_BUILD_NUMBER)</string> | ||
| 23 | + <key>LSRequiresIPhoneOS</key> | ||
| 24 | + <true/> | ||
| 25 | + <key>UILaunchStoryboardName</key> | ||
| 26 | + <string>LaunchScreen</string> | ||
| 27 | + <key>UIMainStoryboardFile</key> | ||
| 28 | + <string>Main</string> | ||
| 29 | + <key>UISupportedInterfaceOrientations</key> | ||
| 30 | + <array> | ||
| 31 | + <string>UIInterfaceOrientationPortrait</string> | ||
| 32 | + <string>UIInterfaceOrientationLandscapeLeft</string> | ||
| 33 | + <string>UIInterfaceOrientationLandscapeRight</string> | ||
| 34 | + </array> | ||
| 35 | + <key>UISupportedInterfaceOrientations~ipad</key> | ||
| 36 | + <array> | ||
| 37 | + <string>UIInterfaceOrientationPortrait</string> | ||
| 38 | + <string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
| 39 | + <string>UIInterfaceOrientationLandscapeLeft</string> | ||
| 40 | + <string>UIInterfaceOrientationLandscapeRight</string> | ||
| 41 | + </array> | ||
| 42 | + <key>UIViewControllerBasedStatusBarAppearance</key> | ||
| 43 | + <false/> | ||
| 44 | +</dict> | ||
| 45 | +</plist> |
wakelock/example/ios/Runner/main.m
0 → 100644
| @@ -2,30 +2,37 @@ import 'package:flutter/material.dart'; | @@ -2,30 +2,37 @@ import 'package:flutter/material.dart'; | ||
| 2 | import 'package:wakelock/wakelock.dart'; | 2 | import 'package:wakelock/wakelock.dart'; |
| 3 | 3 | ||
| 4 | void main() { | 4 | void main() { |
| 5 | - runApp(ExampleApp()); | 5 | + runApp(WakelockExampleApp()); |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | -/// The wakelock implementation is located inside the [FlatButton.onPressed] functions and a [FutureBuilder]. | ||
| 9 | -/// The [FlatButton]'s and the [FutureBuilder] sit inside the [Column] that is a child of the [Scaffold] in [_ExampleAppState]. | ||
| 10 | -class ExampleApp extends StatefulWidget { | ||
| 11 | - const ExampleApp({Key key}) : super(key: key); | ||
| 12 | - | 8 | +/// Example app widget demonstrating how to use the wakelock plugin. |
| 9 | +/// | ||
| 10 | +/// The example implementation is located inside [OutlineButton.onPressed] | ||
| 11 | +/// callback functions and a [FutureBuilder]. | ||
| 12 | +class WakelockExampleApp extends StatefulWidget { | ||
| 13 | @override | 13 | @override |
| 14 | - _ExampleAppState createState() => _ExampleAppState(); | 14 | + _WakelockExampleAppState createState() => _WakelockExampleAppState(); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | -class _ExampleAppState extends State<ExampleApp> { | 17 | +class _WakelockExampleAppState extends State<WakelockExampleApp> { |
| 18 | @override | 18 | @override |
| 19 | Widget build(BuildContext context) { | 19 | Widget build(BuildContext context) { |
| 20 | return MaterialApp( | 20 | return MaterialApp( |
| 21 | home: Scaffold( | 21 | home: Scaffold( |
| 22 | + appBar: AppBar( | ||
| 23 | + title: const Text('Wakelock example app'), | ||
| 24 | + ), | ||
| 22 | body: Center( | 25 | body: Center( |
| 23 | child: Column( | 26 | child: Column( |
| 24 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, | 27 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 25 | children: <Widget>[ | 28 | children: <Widget>[ |
| 26 | - FlatButton( | 29 | + const Spacer( |
| 30 | + flex: 3, | ||
| 31 | + ), | ||
| 32 | + OutlineButton( | ||
| 27 | onPressed: () { | 33 | onPressed: () { |
| 28 | - // The following code will enable the wakelock on Android or iOS using the wakelock plugin. | 34 | + // The following code will enable the wakelock on the device |
| 35 | + // using the wakelock plugin. | ||
| 29 | setState(() { | 36 | setState(() { |
| 30 | Wakelock.enable(); | 37 | Wakelock.enable(); |
| 31 | // You could also use Wakelock.toggle(on: true); | 38 | // You could also use Wakelock.toggle(on: true); |
| @@ -33,9 +40,11 @@ class _ExampleAppState extends State<ExampleApp> { | @@ -33,9 +40,11 @@ class _ExampleAppState extends State<ExampleApp> { | ||
| 33 | }, | 40 | }, |
| 34 | child: const Text('enable wakelock'), | 41 | child: const Text('enable wakelock'), |
| 35 | ), | 42 | ), |
| 36 | - FlatButton( | 43 | + const Spacer(), |
| 44 | + OutlineButton( | ||
| 37 | onPressed: () { | 45 | onPressed: () { |
| 38 | - // The following code will disable the wakelock on Android or iOS using the wakelock plugin. | 46 | + // The following code will disable the wakelock on the device |
| 47 | + // using the wakelock plugin. | ||
| 39 | setState(() { | 48 | setState(() { |
| 40 | Wakelock.disable(); | 49 | Wakelock.disable(); |
| 41 | // You could also use Wakelock.toggle(on: false); | 50 | // You could also use Wakelock.toggle(on: false); |
| @@ -43,16 +52,27 @@ class _ExampleAppState extends State<ExampleApp> { | @@ -43,16 +52,27 @@ class _ExampleAppState extends State<ExampleApp> { | ||
| 43 | }, | 52 | }, |
| 44 | child: const Text('disable wakelock'), | 53 | child: const Text('disable wakelock'), |
| 45 | ), | 54 | ), |
| 55 | + const Spacer( | ||
| 56 | + flex: 2, | ||
| 57 | + ), | ||
| 46 | FutureBuilder( | 58 | FutureBuilder( |
| 47 | - future: Wakelock.isEnabled, | 59 | + future: Wakelock.enabled, |
| 48 | builder: (context, AsyncSnapshot<bool> snapshot) { | 60 | builder: (context, AsyncSnapshot<bool> snapshot) { |
| 49 | - // The use of FutureBuilder is necessary here to await the bool value from isEnabled. | ||
| 50 | - if (!snapshot.hasData) | ||
| 51 | - return Container(); // The Future is retrieved so fast that you will not be able to see any loading indicator. | ||
| 52 | - return Text( | ||
| 53 | - 'wakelock is currently ${snapshot.data ? 'enabled' : 'disabled'}'); | 61 | + // The use of FutureBuilder is necessary here to await the |
| 62 | + // bool value from the `enabled` getter. | ||
| 63 | + if (!snapshot.hasData) { | ||
| 64 | + // The Future is retrieved so fast that you will not be able | ||
| 65 | + // to see any loading indicator. | ||
| 66 | + return Container(); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + return Text('The wakelock is currently ' | ||
| 70 | + '${snapshot.data ? 'enabled' : 'disabled'}.'); | ||
| 54 | }, | 71 | }, |
| 55 | ), | 72 | ), |
| 73 | + const Spacer( | ||
| 74 | + flex: 3, | ||
| 75 | + ), | ||
| 56 | ], | 76 | ], |
| 57 | ), | 77 | ), |
| 58 | ), | 78 | ), |
| 1 | name: wakelock_example | 1 | name: wakelock_example |
| 2 | -description: Demonstrates how to use the wakelock plugin and is used for integration testing. | 2 | +description: >-2 |
| 3 | + Example app demonstrating how to use the wakelock plugin. It also includes integration tests for | ||
| 4 | + testing the plugin in an integrated example. | ||
| 3 | publish_to: 'none' | 5 | publish_to: 'none' |
| 4 | 6 | ||
| 5 | environment: | 7 | environment: |
| @@ -9,15 +11,20 @@ dependencies: | @@ -9,15 +11,20 @@ dependencies: | ||
| 9 | flutter: | 11 | flutter: |
| 10 | sdk: flutter | 12 | sdk: flutter |
| 11 | 13 | ||
| 12 | -dev_dependencies: | ||
| 13 | - pedantic: 1.9.0 | ||
| 14 | - | ||
| 15 | wakelock: | 14 | wakelock: |
| 15 | + # When depending on this package from a real application you should use: | ||
| 16 | + # wakelock: ^x.y.z | ||
| 17 | + # See https://dart.dev/tools/pub/dependencies#version-constraints | ||
| 18 | + # The example app is bundled with the plugin so we use a path dependency on | ||
| 19 | + # the parent directory to use the current plugin's version. | ||
| 16 | path: ../ | 20 | path: ../ |
| 17 | 21 | ||
| 22 | +dev_dependencies: | ||
| 23 | + flutter_test: | ||
| 24 | + sdk: flutter | ||
| 18 | flutter_driver: | 25 | flutter_driver: |
| 19 | sdk: flutter | 26 | sdk: flutter |
| 20 | - test: # This is equivalent to any. | 27 | + integration_test: ^0.9.1 |
| 28 | + test: any | ||
| 21 | 29 | ||
| 22 | -dependency_overrides: | ||
| 23 | - pedantic: 1.9.0 | 30 | + pedantic: ^1.9.2 |
wakelock/example/web/index.html
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html> | ||
| 3 | +<head> | ||
| 4 | + <meta charset="UTF-8"> | ||
| 5 | + <meta content="IE=Edge" http-equiv="X-UA-Compatible"> | ||
| 6 | + <meta name="description" content="Example app demonstrating how to use the wakelock plugin."> | ||
| 7 | + | ||
| 8 | + <!-- iOS meta tags --> | ||
| 9 | + <meta name="apple-mobile-web-app-capable" content="yes"> | ||
| 10 | + <meta name="apple-mobile-web-app-status-bar-style" content="black"> | ||
| 11 | + <meta name="apple-mobile-web-app-title" content="wakelock example"> | ||
| 12 | + | ||
| 13 | + <title>wakelock example</title> | ||
| 14 | + <link rel="manifest" href="manifest.json"> | ||
| 15 | +</head> | ||
| 16 | +<body> | ||
| 17 | + <!-- This script installs service_worker.js to provide PWA functionality to | ||
| 18 | + application. For more information, see: | ||
| 19 | + https://developers.google.com/web/fundamentals/primers/service-workers --> | ||
| 20 | + <script> | ||
| 21 | + if ('serviceWorker' in navigator) { | ||
| 22 | + window.addEventListener('load', function () { | ||
| 23 | + navigator.serviceWorker.register('flutter_service_worker.js'); | ||
| 24 | + }); | ||
| 25 | + } | ||
| 26 | + </script> | ||
| 27 | + <script src="main.dart.js" type="application/javascript"></script> | ||
| 28 | +</body> | ||
| 29 | +</html> |
wakelock/example/web/manifest.json
0 → 100644
| 1 | +{ | ||
| 2 | + "name": "wakelock example", | ||
| 3 | + "short_name": "wakelock", | ||
| 4 | + "start_url": ".", | ||
| 5 | + "display": "standalone", | ||
| 6 | + "background_color": "#0175C2", | ||
| 7 | + "theme_color": "#0175C2", | ||
| 8 | + "description": "Example app demonstrating how to use the wakelock plugin.", | ||
| 9 | + "orientation": "portrait-primary", | ||
| 10 | + "prefer_related_applications": false | ||
| 11 | +} |
wakelock/ios/Assets/.gitkeep
0 → 100644
wakelock/ios/Classes/WakelockPlugin.m
0 → 100644
| 1 | +#import "WakelockPlugin.h" | ||
| 2 | +#import "messages.h" | ||
| 3 | + | ||
| 4 | +@interface WakelockPlugin () <FLTWakelockApi> | ||
| 5 | +@end | ||
| 6 | + | ||
| 7 | +@implementation WakelockPlugin | ||
| 8 | ++ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar { | ||
| 9 | + WakelockPlugin* instance = [[WakelockPlugin alloc] init]; | ||
| 10 | + FLTWakelockApiSetup(registrar.messenger, instance); | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +- (void)toggle:(FLTToggleMessage*)input error:(FlutterError**)error { | ||
| 14 | + NSNumber *enable = input.enable; | ||
| 15 | + NSNumber *enabled = [NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]; | ||
| 16 | + | ||
| 17 | + if (![enable isEqualToNumber:enabled]) { | ||
| 18 | + [[UIApplication sharedApplication] setIdleTimerDisabled:enable.boolValue]; | ||
| 19 | + } | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +- (FLTIsEnabledMessage*)isEnabled:(FlutterError* __autoreleasing *)error { | ||
| 23 | + NSNumber *enabled = [NSNumber numberWithBool:[[UIApplication sharedApplication] isIdleTimerDisabled]]; | ||
| 24 | + | ||
| 25 | + FLTIsEnabledMessage* result = [[FLTIsEnabledMessage alloc] init]; | ||
| 26 | + result.enabled = enabled; | ||
| 27 | + | ||
| 28 | + return result; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +@end |
wakelock/ios/Classes/messages.h
0 → 100644
| 1 | +// Autogenerated from Pigeon (v0.1.7), do not edit directly. | ||
| 2 | +// See also: https://pub.dev/packages/pigeon | ||
| 3 | +#import <Foundation/Foundation.h> | ||
| 4 | +@protocol FlutterBinaryMessenger; | ||
| 5 | +@class FlutterError; | ||
| 6 | +@class FlutterStandardTypedData; | ||
| 7 | + | ||
| 8 | +NS_ASSUME_NONNULL_BEGIN | ||
| 9 | + | ||
| 10 | +@class FLTToggleMessage; | ||
| 11 | +@class FLTIsEnabledMessage; | ||
| 12 | + | ||
| 13 | +@interface FLTToggleMessage : NSObject | ||
| 14 | +@property(nonatomic, strong, nullable) NSNumber * enable; | ||
| 15 | +@end | ||
| 16 | + | ||
| 17 | +@interface FLTIsEnabledMessage : NSObject | ||
| 18 | +@property(nonatomic, strong, nullable) NSNumber * enabled; | ||
| 19 | +@end | ||
| 20 | + | ||
| 21 | +@protocol FLTWakelockApi | ||
| 22 | +-(void)toggle:(FLTToggleMessage*)input error:(FlutterError *_Nullable *_Nonnull)error; | ||
| 23 | +-(nullable FLTIsEnabledMessage *)isEnabled:(FlutterError *_Nullable *_Nonnull)error; | ||
| 24 | +@end | ||
| 25 | + | ||
| 26 | +extern void FLTWakelockApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTWakelockApi> _Nullable api); | ||
| 27 | + | ||
| 28 | +NS_ASSUME_NONNULL_END |
wakelock/ios/Classes/messages.m
0 → 100644
| 1 | +// Autogenerated from Pigeon (v0.1.7), do not edit directly. | ||
| 2 | +// See also: https://pub.dev/packages/pigeon | ||
| 3 | +#import "messages.h" | ||
| 4 | +#import <Flutter/Flutter.h> | ||
| 5 | + | ||
| 6 | +#if !__has_feature(objc_arc) | ||
| 7 | +#error File requires ARC to be enabled. | ||
| 8 | +#endif | ||
| 9 | + | ||
| 10 | +static NSDictionary* wrapResult(NSDictionary *result, FlutterError *error) { | ||
| 11 | + NSDictionary *errorDict = (NSDictionary *)[NSNull null]; | ||
| 12 | + if (error) { | ||
| 13 | + errorDict = [NSDictionary dictionaryWithObjectsAndKeys: | ||
| 14 | + (error.code ? error.code : [NSNull null]), @"code", | ||
| 15 | + (error.message ? error.message : [NSNull null]), @"message", | ||
| 16 | + (error.details ? error.details : [NSNull null]), @"details", | ||
| 17 | + nil]; | ||
| 18 | + } | ||
| 19 | + return [NSDictionary dictionaryWithObjectsAndKeys: | ||
| 20 | + (result ? result : [NSNull null]), @"result", | ||
| 21 | + errorDict, @"error", | ||
| 22 | + nil]; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +@interface FLTToggleMessage () | ||
| 26 | ++(FLTToggleMessage*)fromMap:(NSDictionary*)dict; | ||
| 27 | +-(NSDictionary*)toMap; | ||
| 28 | +@end | ||
| 29 | +@interface FLTIsEnabledMessage () | ||
| 30 | ++(FLTIsEnabledMessage*)fromMap:(NSDictionary*)dict; | ||
| 31 | +-(NSDictionary*)toMap; | ||
| 32 | +@end | ||
| 33 | + | ||
| 34 | +@implementation FLTToggleMessage | ||
| 35 | ++(FLTToggleMessage*)fromMap:(NSDictionary*)dict { | ||
| 36 | + FLTToggleMessage* result = [[FLTToggleMessage alloc] init]; | ||
| 37 | + result.enable = dict[@"enable"]; | ||
| 38 | + if ((NSNull *)result.enable == [NSNull null]) { | ||
| 39 | + result.enable = nil; | ||
| 40 | + } | ||
| 41 | + return result; | ||
| 42 | +} | ||
| 43 | +-(NSDictionary*)toMap { | ||
| 44 | + return [NSDictionary dictionaryWithObjectsAndKeys:(self.enable ? self.enable : [NSNull null]), @"enable", nil]; | ||
| 45 | +} | ||
| 46 | +@end | ||
| 47 | + | ||
| 48 | +@implementation FLTIsEnabledMessage | ||
| 49 | ++(FLTIsEnabledMessage*)fromMap:(NSDictionary*)dict { | ||
| 50 | + FLTIsEnabledMessage* result = [[FLTIsEnabledMessage alloc] init]; | ||
| 51 | + result.enabled = dict[@"enabled"]; | ||
| 52 | + if ((NSNull *)result.enabled == [NSNull null]) { | ||
| 53 | + result.enabled = nil; | ||
| 54 | + } | ||
| 55 | + return result; | ||
| 56 | +} | ||
| 57 | +-(NSDictionary*)toMap { | ||
| 58 | + return [NSDictionary dictionaryWithObjectsAndKeys:(self.enabled ? self.enabled : [NSNull null]), @"enabled", nil]; | ||
| 59 | +} | ||
| 60 | +@end | ||
| 61 | + | ||
| 62 | +void FLTWakelockApiSetup(id<FlutterBinaryMessenger> binaryMessenger, id<FLTWakelockApi> api) { | ||
| 63 | + { | ||
| 64 | + FlutterBasicMessageChannel *channel = | ||
| 65 | + [FlutterBasicMessageChannel | ||
| 66 | + messageChannelWithName:@"dev.flutter.pigeon.WakelockApi.toggle" | ||
| 67 | + binaryMessenger:binaryMessenger]; | ||
| 68 | + if (api) { | ||
| 69 | + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { | ||
| 70 | + FlutterError *error; | ||
| 71 | + FLTToggleMessage *input = [FLTToggleMessage fromMap:message]; | ||
| 72 | + [api toggle:input error:&error]; | ||
| 73 | + callback(wrapResult(nil, error)); | ||
| 74 | + }]; | ||
| 75 | + } | ||
| 76 | + else { | ||
| 77 | + [channel setMessageHandler:nil]; | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + { | ||
| 81 | + FlutterBasicMessageChannel *channel = | ||
| 82 | + [FlutterBasicMessageChannel | ||
| 83 | + messageChannelWithName:@"dev.flutter.pigeon.WakelockApi.isEnabled" | ||
| 84 | + binaryMessenger:binaryMessenger]; | ||
| 85 | + if (api) { | ||
| 86 | + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { | ||
| 87 | + FlutterError *error; | ||
| 88 | + FLTIsEnabledMessage *output = [api isEnabled:&error]; | ||
| 89 | + callback(wrapResult([output toMap], error)); | ||
| 90 | + }]; | ||
| 91 | + } | ||
| 92 | + else { | ||
| 93 | + [channel setMessageHandler:nil]; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | +} |
| @@ -5,19 +5,19 @@ | @@ -5,19 +5,19 @@ | ||
| 5 | Pod::Spec.new do |s| | 5 | Pod::Spec.new do |s| |
| 6 | s.name = 'wakelock' | 6 | s.name = 'wakelock' |
| 7 | s.version = '0.0.1' | 7 | s.version = '0.0.1' |
| 8 | - s.summary = 'A new Flutter plugin.' | 8 | + s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web.' |
| 9 | s.description = <<-DESC | 9 | s.description = <<-DESC |
| 10 | -A new Flutter plugin. | 10 | +Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, and web. |
| 11 | DESC | 11 | DESC |
| 12 | s.homepage = 'http://example.com' | 12 | s.homepage = 'http://example.com' |
| 13 | s.license = { :file => '../LICENSE' } | 13 | s.license = { :file => '../LICENSE' } |
| 14 | s.author = { 'Your Company' => 'email@example.com' } | 14 | s.author = { 'Your Company' => 'email@example.com' } |
| 15 | s.source = { :path => '.' } | 15 | s.source = { :path => '.' } |
| 16 | s.source_files = 'Classes/**/*' | 16 | s.source_files = 'Classes/**/*' |
| 17 | + s.public_header_files = 'Classes/**/*.h' | ||
| 17 | s.dependency 'Flutter' | 18 | s.dependency 'Flutter' |
| 18 | s.platform = :ios, '8.0' | 19 | s.platform = :ios, '8.0' |
| 19 | 20 | ||
| 20 | - # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported. | ||
| 21 | - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' } | ||
| 22 | - s.ios.deployment_target = '8.0' | 21 | + # Flutter.framework does not contain a i386 slice. |
| 22 | + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } | ||
| 23 | end | 23 | end |
wakelock/lib/wakelock.dart
0 → 100644
| 1 | +import 'package:meta/meta.dart'; | ||
| 2 | +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
| 3 | + | ||
| 4 | +final _wakelockPlatformInstance = WakelockPlatformInterface.instance; | ||
| 5 | + | ||
| 6 | +/// Class providing all wakelock functionality using static members. | ||
| 7 | +/// | ||
| 8 | +/// To enable the wakelock, you can use [Wakelock.enable] and to disable it, | ||
| 9 | +/// you can call [Wakelock.disable]. | ||
| 10 | +/// You do not need to worry about making redundant calls, e.g. calling | ||
| 11 | +/// [Wakelock.enable] when the wakelock is already enabled as the plugin handles | ||
| 12 | +/// this for you, i.e. it checks the status to determine if the wakelock is | ||
| 13 | +/// already enabled or disabled. | ||
| 14 | +/// If you want the flexibility to pass a [bool] to control whether the wakelock | ||
| 15 | +/// should be enabled or disabled, you can use [Wakelock.toggle]. | ||
| 16 | +/// | ||
| 17 | +/// The [Wakelock.enabled] getter allows you to retrieve the current wakelock | ||
| 18 | +/// status of the device.. | ||
| 19 | +class Wakelock { | ||
| 20 | + /// Enables the wakelock. | ||
| 21 | + /// | ||
| 22 | + /// This can simply be called using `Wakelock.enable()` and does not return | ||
| 23 | + /// anything. | ||
| 24 | + /// You can await the [Future] to wait for the operation to complete. | ||
| 25 | + /// | ||
| 26 | + /// See also: | ||
| 27 | + /// * [toggle], which allows to enable or disable using a [bool] parameter. | ||
| 28 | + static Future<void> enable() => toggle(enable: true); | ||
| 29 | + | ||
| 30 | + /// Disables the wakelock. | ||
| 31 | + /// | ||
| 32 | + /// This can simply be called using `Wakelock.disable()` and does not return | ||
| 33 | + /// anything. | ||
| 34 | + /// You can await the [Future] to wait for the operation to complete. | ||
| 35 | + /// | ||
| 36 | + /// See also: | ||
| 37 | + /// * [toggle], which allows to enable or disable using a [bool] parameter. | ||
| 38 | + static Future<void> disable() => toggle(enable: false); | ||
| 39 | + | ||
| 40 | + /// Toggles the wakelock on or off. | ||
| 41 | + /// | ||
| 42 | + /// You can simply use this function to toggle the wakelock using a [bool] | ||
| 43 | + /// value (for the [enable] parameter). | ||
| 44 | + /// | ||
| 45 | + /// ```dart | ||
| 46 | + /// // This line keeps the screen on. | ||
| 47 | + /// Wakelock.toggle(enable: true); | ||
| 48 | + /// | ||
| 49 | + /// bool enableWakelock = false; | ||
| 50 | + /// // The following line disables the wakelock. | ||
| 51 | + /// Wakelock.toggle(enable: enableWakelock); | ||
| 52 | + /// ``` | ||
| 53 | + /// | ||
| 54 | + /// You can await the [Future] to wait for the operation to complete. | ||
| 55 | + static Future<void> toggle({ | ||
| 56 | + @required bool enable, | ||
| 57 | + @Deprecated('Use the `enable` parameter instead.') bool on, | ||
| 58 | + }) { | ||
| 59 | + // The checks allow only `on` to be used in the case of old code and | ||
| 60 | + // they encourage to use only `enable` instead (combined with the | ||
| 61 | + // deprecation warning). | ||
| 62 | + assert(enable != null || on != null, | ||
| 63 | + 'The `enable` parameter must not be null when toggling the wakelock.'); | ||
| 64 | + assert( | ||
| 65 | + on == null || enable == null, | ||
| 66 | + 'The `on` parameter has been deprecated; ' | ||
| 67 | + 'specify only the `enable` parameter instead.'); | ||
| 68 | + | ||
| 69 | + return _wakelockPlatformInstance.toggle(enable: enable ?? on); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + /// Returns whether the wakelock is currently enabled or not. | ||
| 73 | + /// | ||
| 74 | + /// If you want to retrieve the current wakelock status, you will have to call | ||
| 75 | + /// [Wakelock.enabled] and await its result: | ||
| 76 | + /// | ||
| 77 | + /// ```dart | ||
| 78 | + /// bool wakelockEnabled = await Wakelock.enabled; | ||
| 79 | + /// ``` | ||
| 80 | + static Future<bool> get enabled => _wakelockPlatformInstance.enabled; | ||
| 81 | + | ||
| 82 | + /// Returns the current wakelock status. | ||
| 83 | + @Deprecated('Use the `enabled` getter instead.') | ||
| 84 | + static Future<bool> get isEnabled => enabled; | ||
| 85 | +} |
wakelock/pigeons/messages.dart
0 → 100644
| 1 | +import 'package:pigeon/pigeon.dart'; | ||
| 2 | + | ||
| 3 | +/// Message for toggling the wakelock on the platform side. | ||
| 4 | +class ToggleMessage { | ||
| 5 | + bool enable; | ||
| 6 | +} | ||
| 7 | + | ||
| 8 | +/// Message for reporting the wakelock state from the platform side. | ||
| 9 | +class IsEnabledMessage { | ||
| 10 | + bool enabled; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +@HostApi(dartHostTestHandler: 'TestWakelockApi') | ||
| 14 | +abstract class WakelockApi { | ||
| 15 | + void toggle(ToggleMessage msg); | ||
| 16 | + | ||
| 17 | + IsEnabledMessage isEnabled(); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +void configurePigeon(PigeonOptions options) { | ||
| 21 | + options | ||
| 22 | + ..dartOut = '../wakelock_platform_interface/lib/messages.dart' | ||
| 23 | + ..objcHeaderOut = 'ios/Classes/messages.h' | ||
| 24 | + ..objcSourceOut = 'ios/Classes/messages.m' | ||
| 25 | + ..objcOptions.prefix = 'FLT' | ||
| 26 | + ..javaOut = 'android/src/main/java/creativemaybeno/wakelock/Messages.java' | ||
| 27 | + ..javaOptions.package = 'creativemaybeno.wakelock'; | ||
| 28 | +} |
| 1 | name: wakelock | 1 | name: wakelock |
| 2 | -description: This plugin allows you to keep Android and iOS devices awake, i.e. prevent the screen from sleeping by toggling the wakelock of the device on or off. | ||
| 3 | -version: 0.1.4+2 | ||
| 4 | -homepage: https://github.com/creativecreatorormaybenot/wakelock | 2 | +description: >-2 |
| 3 | + Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on | ||
| 4 | + Android, iOS, and web. | ||
| 5 | +version: 0.2.0 | ||
| 6 | +homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock | ||
| 5 | 7 | ||
| 6 | environment: | 8 | environment: |
| 7 | - sdk: ">=2.7.0 <3.0.0" | ||
| 8 | - flutter: ">=1.12.0 <2.0.0" | 9 | + sdk: ">=2.8.0 <3.0.0" |
| 10 | + flutter: ">=1.20.0 <2.0.0" | ||
| 9 | 11 | ||
| 10 | dependencies: | 12 | dependencies: |
| 11 | flutter: | 13 | flutter: |
| 12 | sdk: flutter | 14 | sdk: flutter |
| 13 | - wakelock_web: | ||
| 14 | - path: wakelock_web/ | ||
| 15 | 15 | ||
| 16 | -dev_dependencies: | ||
| 17 | - pedantic: 1.9.0 | 16 | + meta: ^1.2.0 |
| 17 | + | ||
| 18 | + wakelock_platform_interface: ^0.1.0 | ||
| 19 | + wakelock_web: ^0.1.0 | ||
| 18 | 20 | ||
| 21 | +dev_dependencies: | ||
| 19 | flutter_test: | 22 | flutter_test: |
| 20 | sdk: flutter | 23 | sdk: flutter |
| 21 | 24 | ||
| 22 | -dependency_overrides: | ||
| 23 | - pedantic: 1.9.0 | 25 | + pedantic: ^1.9.2 |
| 26 | + pigeon: 0.1.7 | ||
| 24 | 27 | ||
| 25 | flutter: | 28 | flutter: |
| 26 | plugin: | 29 | plugin: |
| 27 | platforms: | 30 | platforms: |
| 28 | android: | 31 | android: |
| 29 | - package: creativecreatorormaybenot.wakelock | 32 | + package: creativemaybeno.wakelock |
| 30 | pluginClass: WakelockPlugin | 33 | pluginClass: WakelockPlugin |
| 31 | ios: | 34 | ios: |
| 32 | pluginClass: WakelockPlugin | 35 | pluginClass: WakelockPlugin |
| 33 | web: | 36 | web: |
| 34 | default_package: wakelock_web | 37 | default_package: wakelock_web |
| 35 | - | ||
| 36 | - assets: | ||
| 37 | - - assets/NoSleep.js |
wakelock/test/wakelock_test.dart
0 → 100644
| 1 | +import 'package:flutter_test/flutter_test.dart'; | ||
| 2 | +import 'package:wakelock/wakelock.dart'; | ||
| 3 | +import 'package:wakelock_platform_interface/messages.dart'; | ||
| 4 | + | ||
| 5 | +void main() { | ||
| 6 | + TestWidgetsFlutterBinding.ensureInitialized(); | ||
| 7 | + | ||
| 8 | + group('$Wakelock', () { | ||
| 9 | + FakeWakelockApi fakeWakelock; | ||
| 10 | + | ||
| 11 | + setUpAll(() { | ||
| 12 | + fakeWakelock = FakeWakelockApi(); | ||
| 13 | + }); | ||
| 14 | + | ||
| 15 | + test('toggle enable non-null assertion', () { | ||
| 16 | + expect(() => Wakelock.toggle(enable: null), throwsAssertionError); | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + test('enable', () async { | ||
| 20 | + await Wakelock.enable(); | ||
| 21 | + | ||
| 22 | + expect(fakeWakelock.calls.last, 'toggle'); | ||
| 23 | + expect(fakeWakelock.toggleMessage.enable, isTrue); | ||
| 24 | + }); | ||
| 25 | + | ||
| 26 | + test('disable', () async { | ||
| 27 | + await Wakelock.disable(); | ||
| 28 | + | ||
| 29 | + expect(fakeWakelock.calls.last, 'toggle'); | ||
| 30 | + expect(fakeWakelock.toggleMessage.enable, isFalse); | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + test('toggle', () async { | ||
| 34 | + await Wakelock.toggle(enable: false); | ||
| 35 | + | ||
| 36 | + expect(fakeWakelock.calls.last, 'toggle'); | ||
| 37 | + expect(fakeWakelock.toggleMessage.enable, isFalse); | ||
| 38 | + | ||
| 39 | + await Wakelock.toggle(enable: true); | ||
| 40 | + | ||
| 41 | + expect(fakeWakelock.calls.last, 'toggle'); | ||
| 42 | + expect(fakeWakelock.toggleMessage.enable, isTrue); | ||
| 43 | + }); | ||
| 44 | + | ||
| 45 | + test('enabled', () async { | ||
| 46 | + expect(Wakelock.enabled, completion(isTrue)); | ||
| 47 | + expect(fakeWakelock.calls.last, 'isEnabled'); | ||
| 48 | + }); | ||
| 49 | + }); | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +class FakeWakelockApi extends TestWakelockApi { | ||
| 53 | + FakeWakelockApi() { | ||
| 54 | + TestWakelockApi.setup(this); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + final calls = <String>[]; | ||
| 58 | + ToggleMessage toggleMessage; | ||
| 59 | + | ||
| 60 | + @override | ||
| 61 | + IsEnabledMessage isEnabled() { | ||
| 62 | + calls.add('isEnabled'); | ||
| 63 | + return IsEnabledMessage()..enabled = true; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @override | ||
| 67 | + void toggle(ToggleMessage message) { | ||
| 68 | + calls.add('toggle'); | ||
| 69 | + toggleMessage = message; | ||
| 70 | + ; | ||
| 71 | + } | ||
| 72 | +} |
wakelock_platform_interface/.gitignore
0 → 100644
| 1 | +# Miscellaneous | ||
| 2 | +*.class | ||
| 3 | +*.log | ||
| 4 | +*.pyc | ||
| 5 | +*.swp | ||
| 6 | +.DS_Store | ||
| 7 | +.atom/ | ||
| 8 | +.buildlog/ | ||
| 9 | +.history | ||
| 10 | +.svn/ | ||
| 11 | +.metadata | ||
| 12 | + | ||
| 13 | +# IntelliJ related | ||
| 14 | +*.iml | ||
| 15 | +*.ipr | ||
| 16 | +*.iws | ||
| 17 | +.idea/ | ||
| 18 | + | ||
| 19 | +# The .vscode folder contains launch configuration and tasks you configure in | ||
| 20 | +# VS Code which you may wish to be included in version control, so this line | ||
| 21 | +# is commented out by default. | ||
| 22 | +#.vscode/ | ||
| 23 | + | ||
| 24 | +# Flutter/Dart/Pub related | ||
| 25 | +**/doc/api/ | ||
| 26 | +.dart_tool/ | ||
| 27 | +.flutter-plugins | ||
| 28 | +.flutter-plugins-dependencies | ||
| 29 | +.packages | ||
| 30 | +.pub-cache/ | ||
| 31 | +.pub/ | ||
| 32 | +build/ | ||
| 33 | +pubspec.lock | ||
| 34 | + | ||
| 35 | +# Android related | ||
| 36 | +**/android/**/gradle-wrapper.jar | ||
| 37 | +**/android/.gradle | ||
| 38 | +**/android/captures/ | ||
| 39 | +**/android/gradlew | ||
| 40 | +**/android/gradlew.bat | ||
| 41 | +**/android/local.properties | ||
| 42 | +**/android/**/GeneratedPluginRegistrant.java | ||
| 43 | + | ||
| 44 | +# iOS/XCode related | ||
| 45 | +**/ios/**/*.mode1v3 | ||
| 46 | +**/ios/**/*.mode2v3 | ||
| 47 | +**/ios/**/*.moved-aside | ||
| 48 | +**/ios/**/*.pbxuser | ||
| 49 | +**/ios/**/*.perspectivev3 | ||
| 50 | +**/ios/**/*sync/ | ||
| 51 | +**/ios/**/.sconsign.dblite | ||
| 52 | +**/ios/**/.tags* | ||
| 53 | +**/ios/**/.vagrant/ | ||
| 54 | +**/ios/**/DerivedData/ | ||
| 55 | +**/ios/**/Icon? | ||
| 56 | +**/ios/**/Pods/ | ||
| 57 | +**/ios/**/.symlinks/ | ||
| 58 | +**/ios/**/profile | ||
| 59 | +**/ios/**/xcuserdata | ||
| 60 | +**/ios/.generated/ | ||
| 61 | +**/ios/Flutter/App.framework | ||
| 62 | +**/ios/Flutter/Flutter.framework | ||
| 63 | +**/ios/Flutter/Flutter.podspec | ||
| 64 | +**/ios/Flutter/Generated.xcconfig | ||
| 65 | +**/ios/Flutter/app.flx | ||
| 66 | +**/ios/Flutter/app.zip | ||
| 67 | +**/ios/Flutter/flutter_assets/ | ||
| 68 | +**/ios/Flutter/flutter_export_environment.sh | ||
| 69 | +**/ios/ServiceDefinitions.json | ||
| 70 | +**/ios/Runner/GeneratedPluginRegistrant.* | ||
| 71 | + | ||
| 72 | +# Exceptions to above rules. | ||
| 73 | +!**/ios/**/default.mode1v3 | ||
| 74 | +!**/ios/**/default.mode2v3 | ||
| 75 | +!**/ios/**/default.pbxuser | ||
| 76 | +!**/ios/**/default.perspectivev3 |
wakelock_platform_interface/CHANGELOG.md
0 → 100644
wakelock_platform_interface/LICENSE
0 → 100644
| 1 | +BSD 3-Clause License | ||
| 2 | + | ||
| 3 | +Copyright (c) 2020, creativecreatorormaybenot | ||
| 4 | +All rights reserved. | ||
| 5 | + | ||
| 6 | +Redistribution and use in source and binary forms, with or without | ||
| 7 | +modification, are permitted provided that the following conditions are met: | ||
| 8 | + | ||
| 9 | +1. Redistributions of source code must retain the above copyright notice, this | ||
| 10 | + list of conditions and the following disclaimer. | ||
| 11 | + | ||
| 12 | +2. Redistributions in binary form must reproduce the above copyright notice, | ||
| 13 | + this list of conditions and the following disclaimer in the documentation | ||
| 14 | + and/or other materials provided with the distribution. | ||
| 15 | + | ||
| 16 | +3. Neither the name of the copyright holder nor the names of its | ||
| 17 | + contributors may be used to endorse or promote products derived from | ||
| 18 | + this software without specific prior written permission. | ||
| 19 | + | ||
| 20 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 21 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 22 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 23 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| 24 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 25 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 26 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 27 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 28 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 29 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
wakelock_platform_interface/README.md
0 → 100644
| 1 | +# wakelock_platform_interface [](https://pub.dev/packages/wakelock_platform_interface) [](https://github.com/creativecreatorormaybenot/wakelock) | ||
| 2 | + | ||
| 3 | +A common platform interface for the [wakelock plugin][wakelock GitHub] used by the different | ||
| 4 | +platform implementations. | ||
| 5 | + | ||
| 6 | +The practices for the implementation have been adapted from the [video_player_platform_interface] | ||
| 7 | +package. | ||
| 8 | + | ||
| 9 | +[wakelock GitHub]: https://github.com/creativecreatorormaybenot/wakelock | ||
| 10 | +[video_player_platform_interface]: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface |
| 1 | +// Autogenerated from Pigeon (v0.1.7), do not edit directly. | ||
| 2 | +// See also: https://pub.dev/packages/pigeon | ||
| 3 | +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import | ||
| 4 | +// @dart = 2.8 | ||
| 5 | +import 'dart:async'; | ||
| 6 | +import 'package:flutter/services.dart'; | ||
| 7 | +import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; | ||
| 8 | + | ||
| 9 | +class ToggleMessage { | ||
| 10 | + bool enable; | ||
| 11 | + // ignore: unused_element | ||
| 12 | + Map<dynamic, dynamic> _toMap() { | ||
| 13 | + final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{}; | ||
| 14 | + pigeonMap['enable'] = enable; | ||
| 15 | + return pigeonMap; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + // ignore: unused_element | ||
| 19 | + static ToggleMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
| 20 | + if (pigeonMap == null) { | ||
| 21 | + return null; | ||
| 22 | + } | ||
| 23 | + final ToggleMessage result = ToggleMessage(); | ||
| 24 | + result.enable = pigeonMap['enable']; | ||
| 25 | + return result; | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +class IsEnabledMessage { | ||
| 30 | + bool enabled; | ||
| 31 | + // ignore: unused_element | ||
| 32 | + Map<dynamic, dynamic> _toMap() { | ||
| 33 | + final Map<dynamic, dynamic> pigeonMap = <dynamic, dynamic>{}; | ||
| 34 | + pigeonMap['enabled'] = enabled; | ||
| 35 | + return pigeonMap; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + // ignore: unused_element | ||
| 39 | + static IsEnabledMessage _fromMap(Map<dynamic, dynamic> pigeonMap) { | ||
| 40 | + if (pigeonMap == null) { | ||
| 41 | + return null; | ||
| 42 | + } | ||
| 43 | + final IsEnabledMessage result = IsEnabledMessage(); | ||
| 44 | + result.enabled = pigeonMap['enabled']; | ||
| 45 | + return result; | ||
| 46 | + } | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +class WakelockApi { | ||
| 50 | + Future<void> toggle(ToggleMessage arg) async { | ||
| 51 | + final Map<dynamic, dynamic> requestMap = arg._toMap(); | ||
| 52 | + const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( | ||
| 53 | + 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
| 54 | + | ||
| 55 | + final Map<dynamic, dynamic> replyMap = await channel.send(requestMap); | ||
| 56 | + if (replyMap == null) { | ||
| 57 | + throw PlatformException( | ||
| 58 | + code: 'channel-error', | ||
| 59 | + message: 'Unable to establish connection on channel.', | ||
| 60 | + details: null); | ||
| 61 | + } else if (replyMap['error'] != null) { | ||
| 62 | + final Map<dynamic, dynamic> error = replyMap['error']; | ||
| 63 | + throw PlatformException( | ||
| 64 | + code: error['code'], | ||
| 65 | + message: error['message'], | ||
| 66 | + details: error['details']); | ||
| 67 | + } else { | ||
| 68 | + // noop | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + Future<IsEnabledMessage> isEnabled() async { | ||
| 73 | + const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( | ||
| 74 | + 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
| 75 | + | ||
| 76 | + final Map<dynamic, dynamic> replyMap = await channel.send(null); | ||
| 77 | + if (replyMap == null) { | ||
| 78 | + throw PlatformException( | ||
| 79 | + code: 'channel-error', | ||
| 80 | + message: 'Unable to establish connection on channel.', | ||
| 81 | + details: null); | ||
| 82 | + } else if (replyMap['error'] != null) { | ||
| 83 | + final Map<dynamic, dynamic> error = replyMap['error']; | ||
| 84 | + throw PlatformException( | ||
| 85 | + code: error['code'], | ||
| 86 | + message: error['message'], | ||
| 87 | + details: error['details']); | ||
| 88 | + } else { | ||
| 89 | + return IsEnabledMessage._fromMap(replyMap['result']); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +abstract class TestWakelockApi { | ||
| 95 | + void toggle(ToggleMessage arg); | ||
| 96 | + IsEnabledMessage isEnabled(); | ||
| 97 | + static void setup(TestWakelockApi api) { | ||
| 98 | + { | ||
| 99 | + const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( | ||
| 100 | + 'dev.flutter.pigeon.WakelockApi.toggle', StandardMessageCodec()); | ||
| 101 | + channel.setMockMessageHandler((dynamic message) async { | ||
| 102 | + final Map<dynamic, dynamic> mapMessage = | ||
| 103 | + message as Map<dynamic, dynamic>; | ||
| 104 | + final ToggleMessage input = ToggleMessage._fromMap(mapMessage); | ||
| 105 | + api.toggle(input); | ||
| 106 | + return <dynamic, dynamic>{}; | ||
| 107 | + }); | ||
| 108 | + } | ||
| 109 | + { | ||
| 110 | + const BasicMessageChannel<dynamic> channel = BasicMessageChannel<dynamic>( | ||
| 111 | + 'dev.flutter.pigeon.WakelockApi.isEnabled', StandardMessageCodec()); | ||
| 112 | + channel.setMockMessageHandler((dynamic message) async { | ||
| 113 | + final IsEnabledMessage output = api.isEnabled(); | ||
| 114 | + return <dynamic, dynamic>{'result': output._toMap()}; | ||
| 115 | + }); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | +} |
| 1 | +import 'package:wakelock_platform_interface/messages.dart'; | ||
| 2 | +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
| 3 | + | ||
| 4 | +/// Method channel implementation of the [WakelockPlatformInterface]. | ||
| 5 | +class MethodChannelWakelock extends WakelockPlatformInterface { | ||
| 6 | + final _api = WakelockApi(); | ||
| 7 | + | ||
| 8 | + @override | ||
| 9 | + Future<bool> get enabled async { | ||
| 10 | + final message = await _api.isEnabled(); | ||
| 11 | + | ||
| 12 | + return message.enabled; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + @override | ||
| 16 | + Future<void> toggle({bool enable}) async { | ||
| 17 | + assert(enable != null); | ||
| 18 | + | ||
| 19 | + final message = ToggleMessage(); | ||
| 20 | + message.enable = enable; | ||
| 21 | + | ||
| 22 | + await _api.toggle(message); | ||
| 23 | + } | ||
| 24 | +} |
| 1 | +import 'package:meta/meta.dart'; | ||
| 2 | +import 'package:wakelock_platform_interface/method_channel_wakelock.dart'; | ||
| 3 | + | ||
| 4 | +/// The interface that implementations of wakelock must implement. | ||
| 5 | +/// | ||
| 6 | +/// Platform implementations should extend this class rather than implement it | ||
| 7 | +/// because `implements` does not consider newly added methods to be breaking | ||
| 8 | +/// changes. Extending this class (using `extends`) ensures that the subclass | ||
| 9 | +/// will get the default implementation. | ||
| 10 | +abstract class WakelockPlatformInterface { | ||
| 11 | + static WakelockPlatformInterface _instance = MethodChannelWakelock(); | ||
| 12 | + | ||
| 13 | + /// The default instance of the [WakelockPlatformInterface] to use. | ||
| 14 | + /// | ||
| 15 | + /// Platform-specific plugins should override this with their own | ||
| 16 | + /// platform-specific class that extends [WakelockPlatformInterface] when they | ||
| 17 | + /// register themselves. | ||
| 18 | + /// | ||
| 19 | + /// Defaults to [MethodChannelWakelock]. | ||
| 20 | + static WakelockPlatformInterface get instance => _instance; | ||
| 21 | + | ||
| 22 | + /// Sets the default instance of the [WakelockPlatformInterface]. | ||
| 23 | + /// | ||
| 24 | + /// This will be removed after https://github.com/flutter/flutter/issues/43368 | ||
| 25 | + /// has been resolved. | ||
| 26 | + static set instance(WakelockPlatformInterface instance) { | ||
| 27 | + if (!instance.isMock) { | ||
| 28 | + try { | ||
| 29 | + instance._verifyProvidesDefaultImplementations(); | ||
| 30 | + } on NoSuchMethodError catch (_) { | ||
| 31 | + throw AssertionError( | ||
| 32 | + 'Platform interfaces must not be implemented with `implements`'); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + _instance = instance; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /// Only mock implementations should set this to true. | ||
| 39 | + /// | ||
| 40 | + /// Mockito mocks are implementing this class with `implements`, which is | ||
| 41 | + /// forbidden for anything other than mocks (see class docs). This property | ||
| 42 | + /// provides a backdoor for mockito mocks to skip the verification that the | ||
| 43 | + /// class is not implemented with `implements`. | ||
| 44 | + @visibleForTesting | ||
| 45 | + bool get isMock => false; | ||
| 46 | + | ||
| 47 | + /// Toggles the wakelock based on the given [enable] value. | ||
| 48 | + Future<void> toggle({@required bool enable}) { | ||
| 49 | + throw UnimplementedError('toggle() has not been implemented.'); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /// Returns whether the wakelock is enabled or not. | ||
| 53 | + Future<bool> get enabled { | ||
| 54 | + throw UnimplementedError('isEnabled has not been implemented.'); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + // This method makes sure that VideoPlayer isn't implemented with `implements`. | ||
| 58 | + // | ||
| 59 | + // See class doc for more details on why implementing this class is forbidden. | ||
| 60 | + // | ||
| 61 | + // This private method is called by the instance setter, which fails if the | ||
| 62 | + // class is implemented with `implements`. | ||
| 63 | + void _verifyProvidesDefaultImplementations() {} | ||
| 64 | +} |
wakelock_platform_interface/pubspec.yaml
0 → 100644
| 1 | +name: wakelock_platform_interface | ||
| 2 | +description: >-2 | ||
| 3 | + A common platform interface for the wakelock plugin used by the different platform | ||
| 4 | + implementations. | ||
| 5 | +version: 0.1.0 | ||
| 6 | +homepage: >-2 | ||
| 7 | + https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface | ||
| 8 | + | ||
| 9 | +environment: | ||
| 10 | + sdk: ">=2.8.0 <3.0.0" | ||
| 11 | + flutter: ">=1.17.0 <2.0.0" | ||
| 12 | + | ||
| 13 | +dependencies: | ||
| 14 | + flutter: | ||
| 15 | + sdk: flutter | ||
| 16 | + | ||
| 17 | + meta: ^1.2.0 | ||
| 18 | + | ||
| 19 | +dev_dependencies: | ||
| 20 | + flutter_test: | ||
| 21 | + sdk: flutter | ||
| 22 | + | ||
| 23 | + mockito: ^4.1.2 | ||
| 24 | + pedantic: ^1.9.2 |
| 1 | +import 'package:flutter_test/flutter_test.dart'; | ||
| 2 | +import 'package:mockito/mockito.dart'; | ||
| 3 | +import 'package:wakelock_platform_interface/messages.dart'; | ||
| 4 | +import 'package:wakelock_platform_interface/method_channel_wakelock.dart'; | ||
| 5 | +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
| 6 | + | ||
| 7 | +class _ApiLogger implements TestWakelockApi { | ||
| 8 | + final List<String> log = []; | ||
| 9 | + ToggleMessage toggleMessage; | ||
| 10 | + | ||
| 11 | + @override | ||
| 12 | + IsEnabledMessage isEnabled() { | ||
| 13 | + log.add('isEnabled'); | ||
| 14 | + return IsEnabledMessage()..enabled = true; | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + @override | ||
| 18 | + void toggle(ToggleMessage message) { | ||
| 19 | + log.add('toggle'); | ||
| 20 | + toggleMessage = message; | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +void main() { | ||
| 25 | + TestWidgetsFlutterBinding.ensureInitialized(); | ||
| 26 | + | ||
| 27 | + group('$WakelockPlatformInterface', () { | ||
| 28 | + test('$MethodChannelWakelock() is the default instance', () { | ||
| 29 | + expect(WakelockPlatformInterface.instance, | ||
| 30 | + isInstanceOf<MethodChannelWakelock>()); | ||
| 31 | + }); | ||
| 32 | + | ||
| 33 | + test('Cannot be implemented with `implements`', () { | ||
| 34 | + expect(() { | ||
| 35 | + WakelockPlatformInterface.instance = | ||
| 36 | + ImplementsWakelockPlatformInterface(); | ||
| 37 | + }, throwsA(isInstanceOf<AssertionError>())); | ||
| 38 | + }); | ||
| 39 | + | ||
| 40 | + test('Can be mocked with `implements`', () { | ||
| 41 | + final mock = ImplementsWakelockPlatformInterface(); | ||
| 42 | + when(mock.isMock).thenReturn(true); | ||
| 43 | + WakelockPlatformInterface.instance = mock; | ||
| 44 | + }); | ||
| 45 | + | ||
| 46 | + test('Can be extended', () { | ||
| 47 | + WakelockPlatformInterface.instance = ExtendsVideoPlayerPlatform(); | ||
| 48 | + }); | ||
| 49 | + }); | ||
| 50 | + | ||
| 51 | + group('$MethodChannelWakelock', () { | ||
| 52 | + final wakelock = MethodChannelWakelock(); | ||
| 53 | + _ApiLogger logger; | ||
| 54 | + | ||
| 55 | + setUp(() { | ||
| 56 | + logger = _ApiLogger(); | ||
| 57 | + TestWakelockApi.setup(logger); | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + test('toggle', () async { | ||
| 61 | + await wakelock.toggle(enable: true); | ||
| 62 | + | ||
| 63 | + expect(logger.log.last, 'toggle'); | ||
| 64 | + expect(logger.toggleMessage.enable, isTrue); | ||
| 65 | + | ||
| 66 | + await wakelock.toggle(enable: false); | ||
| 67 | + | ||
| 68 | + expect(logger.log.last, 'toggle'); | ||
| 69 | + expect(logger.log, hasLength(2)); | ||
| 70 | + expect(logger.toggleMessage.enable, isFalse); | ||
| 71 | + }); | ||
| 72 | + | ||
| 73 | + test('enabled', () async { | ||
| 74 | + final enabled = await wakelock.enabled; | ||
| 75 | + | ||
| 76 | + expect(logger.log.last, 'isEnabled'); | ||
| 77 | + expect(enabled, isTrue); | ||
| 78 | + }); | ||
| 79 | + }); | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +class ImplementsWakelockPlatformInterface extends Mock | ||
| 83 | + implements WakelockPlatformInterface {} | ||
| 84 | + | ||
| 85 | +class ExtendsVideoPlayerPlatform extends WakelockPlatformInterface {} |
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | .buildlog/ | 8 | .buildlog/ |
| 9 | .history | 9 | .history |
| 10 | .svn/ | 10 | .svn/ |
| 11 | +.metadata | ||
| 11 | 12 | ||
| 12 | # IntelliJ related | 13 | # IntelliJ related |
| 13 | *.iml | 14 | *.iml |
| @@ -28,24 +29,48 @@ | @@ -28,24 +29,48 @@ | ||
| 28 | .packages | 29 | .packages |
| 29 | .pub-cache/ | 30 | .pub-cache/ |
| 30 | .pub/ | 31 | .pub/ |
| 31 | -/build/ | ||
| 32 | - | ||
| 33 | -# Web related | ||
| 34 | -lib/generated_plugin_registrant.dart | 32 | +build/ |
| 33 | +pubspec.lock | ||
| 35 | 34 | ||
| 36 | -# Symbolication related | ||
| 37 | -app.*.symbols | 35 | +# Android related |
| 36 | +**/android/**/gradle-wrapper.jar | ||
| 37 | +**/android/.gradle | ||
| 38 | +**/android/captures/ | ||
| 39 | +**/android/gradlew | ||
| 40 | +**/android/gradlew.bat | ||
| 41 | +**/android/local.properties | ||
| 42 | +**/android/**/GeneratedPluginRegistrant.java | ||
| 38 | 43 | ||
| 39 | -# Obfuscation related | ||
| 40 | -app.*.map.json | 44 | +# iOS/XCode related |
| 45 | +**/ios/**/*.mode1v3 | ||
| 46 | +**/ios/**/*.mode2v3 | ||
| 47 | +**/ios/**/*.moved-aside | ||
| 48 | +**/ios/**/*.pbxuser | ||
| 49 | +**/ios/**/*.perspectivev3 | ||
| 50 | +**/ios/**/*sync/ | ||
| 51 | +**/ios/**/.sconsign.dblite | ||
| 52 | +**/ios/**/.tags* | ||
| 53 | +**/ios/**/.vagrant/ | ||
| 54 | +**/ios/**/DerivedData/ | ||
| 55 | +**/ios/**/Icon? | ||
| 56 | +**/ios/**/Pods/ | ||
| 57 | +**/ios/**/.symlinks/ | ||
| 58 | +**/ios/**/profile | ||
| 59 | +**/ios/**/xcuserdata | ||
| 60 | +**/ios/.generated/ | ||
| 61 | +**/ios/Flutter/App.framework | ||
| 62 | +**/ios/Flutter/Flutter.framework | ||
| 63 | +**/ios/Flutter/Flutter.podspec | ||
| 64 | +**/ios/Flutter/Generated.xcconfig | ||
| 65 | +**/ios/Flutter/app.flx | ||
| 66 | +**/ios/Flutter/app.zip | ||
| 67 | +**/ios/Flutter/flutter_assets/ | ||
| 68 | +**/ios/Flutter/flutter_export_environment.sh | ||
| 69 | +**/ios/ServiceDefinitions.json | ||
| 70 | +**/ios/Runner/GeneratedPluginRegistrant.* | ||
| 41 | 71 | ||
| 42 | # Exceptions to above rules. | 72 | # Exceptions to above rules. |
| 43 | -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages | ||
| 44 | - | ||
| 45 | -# Cleanliness | ||
| 46 | -pubspec.lock | ||
| 47 | -.metadata | ||
| 48 | -test | ||
| 49 | -ios | ||
| 50 | -android | ||
| 51 | -web | 73 | +!**/ios/**/default.mode1v3 |
| 74 | +!**/ios/**/default.mode2v3 | ||
| 75 | +!**/ios/**/default.pbxuser | ||
| 76 | +!**/ios/**/default.perspectivev3 |
| 1 | -../LICENSE | ||
| 1 | +BSD 3-Clause License | ||
| 2 | + | ||
| 3 | +Copyright (c) 2020, creativecreatorormaybenot | ||
| 4 | +All rights reserved. | ||
| 5 | + | ||
| 6 | +Redistribution and use in source and binary forms, with or without | ||
| 7 | +modification, are permitted provided that the following conditions are met: | ||
| 8 | + | ||
| 9 | +1. Redistributions of source code must retain the above copyright notice, this | ||
| 10 | + list of conditions and the following disclaimer. | ||
| 11 | + | ||
| 12 | +2. Redistributions in binary form must reproduce the above copyright notice, | ||
| 13 | + this list of conditions and the following disclaimer in the documentation | ||
| 14 | + and/or other materials provided with the distribution. | ||
| 15 | + | ||
| 16 | +3. Neither the name of the copyright holder nor the names of its | ||
| 17 | + contributors may be used to endorse or promote products derived from | ||
| 18 | + this software without specific prior written permission. | ||
| 19 | + | ||
| 20 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 21 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 22 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 23 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
| 24 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 25 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 26 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 27 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
| 28 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 29 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 1 | -../README.md | ||
| 1 | +# wakelock_web [](https://pub.dev/packages/wakelock_web) [](https://github.com/creativecreatorormaybenot/wakelock) | ||
| 2 | + | ||
| 3 | +Web platform implementation of the `wakelock_platform_interface` for the | ||
| 4 | +[wakelock plugin][wakelock GitHub]. | ||
| 5 | + | ||
| 6 | +## Getting started | ||
| 7 | + | ||
| 8 | +If you want to use the wakelock plugin on web, see the [main `wakelock` plugin package](https://pub.dev/packages/wakelock). | ||
| 9 | + | ||
| 10 | +## Implementation | ||
| 11 | + | ||
| 12 | +The web implementation is based on [`NoSleep.js`](https://github.com/richtr/NoSleep.js/), i.e. | ||
| 13 | +the `assets` include a version that was modified to work with the wakelock plugin. | ||
| 14 | +This supports the [Screen Wake Lock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) | ||
| 15 | +if available. | ||
| 16 | + | ||
| 17 | +[wakelock GitHub]: https://github.com/creativecreatorormaybenot/wakelock |
| 1 | var webm = | 1 | var webm = |
| 2 | - 'data:video/webm;base64,GkXfo0AgQoaBAUL3gQFC8oEEQvOBCEKCQAR3ZWJtQoeBAkKFgQIYU4BnQI0VSalmQCgq17FAAw9CQE2AQAZ3aGFtbXlXQUAGd2hhbW15RIlACECPQAAAAAAAFlSua0AxrkAu14EBY8WBAZyBACK1nEADdW5khkAFVl9WUDglhohAA1ZQOIOBAeBABrCBCLqBCB9DtnVAIueBAKNAHIEAAIAwAQCdASoIAAgAAUAmJaQAA3AA/vz0AAA='; | 2 | + 'data:video/webm;base64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AgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA=' |
| 5 | 5 | ||
| 6 | var _createClass = (function () { | 6 | var _createClass = (function () { |
| 7 | function defineProperties(target, props) { | 7 | function defineProperties(target, props) { |
| 8 | for (var i = 0; i < props.length; i++) { | 8 | for (var i = 0; i < props.length; i++) { |
| 9 | - var descriptor = props[i]; | ||
| 10 | - descriptor.enumerable = descriptor.enumerable || false; | ||
| 11 | - descriptor.configurable = true; | ||
| 12 | - if ('value' in descriptor) descriptor.writable = true; | ||
| 13 | - Object.defineProperty(target, descriptor.key, descriptor); | 9 | + var descriptor = props[i] |
| 10 | + descriptor.enumerable = descriptor.enumerable || false | ||
| 11 | + descriptor.configurable = true | ||
| 12 | + if ('value' in descriptor) descriptor.writable = true | ||
| 13 | + Object.defineProperty(target, descriptor.key, descriptor) | ||
| 14 | } | 14 | } |
| 15 | } | 15 | } |
| 16 | return function (Constructor, protoProps, staticProps) { | 16 | return function (Constructor, protoProps, staticProps) { |
| 17 | - if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
| 18 | - if (staticProps) defineProperties(Constructor, staticProps); | ||
| 19 | - return Constructor; | ||
| 20 | - }; | ||
| 21 | -})(); | 17 | + if (protoProps) defineProperties(Constructor.prototype, protoProps) |
| 18 | + if (staticProps) defineProperties(Constructor, staticProps) | ||
| 19 | + return Constructor | ||
| 20 | + } | ||
| 21 | +})() | ||
| 22 | 22 | ||
| 23 | function _classCallCheck(instance, Constructor) { | 23 | function _classCallCheck(instance, Constructor) { |
| 24 | if (!(instance instanceof Constructor)) { | 24 | if (!(instance instanceof Constructor)) { |
| 25 | - throw new TypeError('Cannot call a class as a function'); | 25 | + throw new TypeError('Cannot call a class as a function') |
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| 28 | 28 | ||
| @@ -40,54 +40,57 @@ var oldIOS = | @@ -40,54 +40,57 @@ var oldIOS = | ||
| 40 | .replace('_', '.') | 40 | .replace('_', '.') |
| 41 | .replace('_', '') | 41 | .replace('_', '') |
| 42 | ) < 10 && | 42 | ) < 10 && |
| 43 | - !window.MSStream; | 43 | + !window.MSStream |
| 44 | 44 | ||
| 45 | // Detect native Wake Lock API support | 45 | // Detect native Wake Lock API support |
| 46 | -var nativeWakeLock = 'wakeLock' in navigator; | 46 | +var nativeWakeLock = 'wakeLock' in navigator |
| 47 | 47 | ||
| 48 | var NoSleep = (function () { | 48 | var NoSleep = (function () { |
| 49 | + var _releasedNative = true | ||
| 50 | + var _nativeRequestInProgress = false | ||
| 51 | + | ||
| 49 | function NoSleep() { | 52 | function NoSleep() { |
| 50 | - var _this = this; | 53 | + var _this = this |
| 51 | 54 | ||
| 52 | - _classCallCheck(this, NoSleep); | 55 | + _classCallCheck(this, NoSleep) |
| 53 | 56 | ||
| 54 | if (nativeWakeLock) { | 57 | if (nativeWakeLock) { |
| 55 | - this._wakeLock = null; | 58 | + this._wakeLock = null |
| 56 | var handleVisibilityChange = function handleVisibilityChange() { | 59 | var handleVisibilityChange = function handleVisibilityChange() { |
| 57 | if ( | 60 | if ( |
| 58 | _this._wakeLock !== null && | 61 | _this._wakeLock !== null && |
| 59 | document.visibilityState === 'visible' | 62 | document.visibilityState === 'visible' |
| 60 | ) { | 63 | ) { |
| 61 | - _this.enable(); | 64 | + _this.enable() |
| 62 | } | 65 | } |
| 63 | - }; | ||
| 64 | - document.addEventListener('visibilitychange', handleVisibilityChange); | ||
| 65 | - document.addEventListener('fullscreenchange', handleVisibilityChange); | 66 | + } |
| 67 | + document.addEventListener('visibilitychange', handleVisibilityChange) | ||
| 68 | + document.addEventListener('fullscreenchange', handleVisibilityChange) | ||
| 66 | } else if (oldIOS) { | 69 | } else if (oldIOS) { |
| 67 | - this.noSleepTimer = null; | 70 | + this.noSleepTimer = null |
| 68 | } else { | 71 | } else { |
| 69 | // Set up no sleep video element | 72 | // Set up no sleep video element |
| 70 | - this.noSleepVideo = document.createElement('video'); | 73 | + this.noSleepVideo = document.createElement('video') |
| 71 | 74 | ||
| 72 | - this.noSleepVideo.setAttribute('title', 'No Sleep'); | ||
| 73 | - this.noSleepVideo.setAttribute('playsinline', ''); | 75 | + this.noSleepVideo.setAttribute('title', 'No Sleep') |
| 76 | + this.noSleepVideo.setAttribute('playsinline', '') | ||
| 74 | 77 | ||
| 75 | - this._addSourceToVideo(this.noSleepVideo, 'webm', webm); | ||
| 76 | - this._addSourceToVideo(this.noSleepVideo, 'mp4', mp4); | 78 | + this._addSourceToVideo(this.noSleepVideo, 'webm', webm) |
| 79 | + this._addSourceToVideo(this.noSleepVideo, 'mp4', mp4) | ||
| 77 | 80 | ||
| 78 | this.noSleepVideo.addEventListener('loadedmetadata', function () { | 81 | this.noSleepVideo.addEventListener('loadedmetadata', function () { |
| 79 | if (_this.noSleepVideo.duration <= 1) { | 82 | if (_this.noSleepVideo.duration <= 1) { |
| 80 | // webm source | 83 | // webm source |
| 81 | - _this.noSleepVideo.setAttribute('loop', ''); | 84 | + _this.noSleepVideo.setAttribute('loop', '') |
| 82 | } else { | 85 | } else { |
| 83 | // mp4 source | 86 | // mp4 source |
| 84 | _this.noSleepVideo.addEventListener('timeupdate', function () { | 87 | _this.noSleepVideo.addEventListener('timeupdate', function () { |
| 85 | if (_this.noSleepVideo.currentTime > 0.5) { | 88 | if (_this.noSleepVideo.currentTime > 0.5) { |
| 86 | - _this.noSleepVideo.currentTime = Math.random(); | 89 | + _this.noSleepVideo.currentTime = Math.random() |
| 87 | } | 90 | } |
| 88 | - }); | 91 | + }) |
| 89 | } | 92 | } |
| 90 | - }); | 93 | + }) |
| 91 | } | 94 | } |
| 92 | } | 95 | } |
| 93 | 96 | ||
| @@ -95,46 +98,48 @@ var NoSleep = (function () { | @@ -95,46 +98,48 @@ var NoSleep = (function () { | ||
| 95 | { | 98 | { |
| 96 | key: '_addSourceToVideo', | 99 | key: '_addSourceToVideo', |
| 97 | value: function _addSourceToVideo(element, type, dataURI) { | 100 | value: function _addSourceToVideo(element, type, dataURI) { |
| 98 | - var source = document.createElement('source'); | ||
| 99 | - source.src = dataURI; | ||
| 100 | - source.type = 'video/' + type; | ||
| 101 | - element.appendChild(source); | 101 | + var source = document.createElement('source') |
| 102 | + source.src = dataURI | ||
| 103 | + source.type = 'video/' + type | ||
| 104 | + element.appendChild(source) | ||
| 102 | }, | 105 | }, |
| 103 | }, | 106 | }, |
| 104 | { | 107 | { |
| 105 | key: 'enable', | 108 | key: 'enable', |
| 106 | value: function enable() { | 109 | value: function enable() { |
| 107 | - var _this2 = this; | 110 | + var _this2 = this |
| 108 | 111 | ||
| 109 | if (nativeWakeLock) { | 112 | if (nativeWakeLock) { |
| 113 | + _nativeRequestInProgress = true | ||
| 110 | navigator.wakeLock | 114 | navigator.wakeLock |
| 111 | .request('screen') | 115 | .request('screen') |
| 112 | .then(function (wakeLock) { | 116 | .then(function (wakeLock) { |
| 113 | - _this2._wakeLock = wakeLock; | ||
| 114 | - console.log('Wake Lock active.'); | 117 | + _releasedNative = false |
| 118 | + _nativeRequestInProgress = false | ||
| 119 | + | ||
| 120 | + _this2._wakeLock = wakeLock | ||
| 115 | _this2._wakeLock.addEventListener('release', function () { | 121 | _this2._wakeLock.addEventListener('release', function () { |
| 116 | - // ToDo: Potentially emit an event for the page to observe since | ||
| 117 | - // Wake Lock releases happen when page visibility changes. | ||
| 118 | - // (https://web.dev/wakelock/#wake-lock-lifecycle) | ||
| 119 | - console.log('Wake Lock released.'); | ||
| 120 | - }); | 122 | + _releasedNative = true |
| 123 | + _this2._wakeLock = null | ||
| 124 | + }) | ||
| 121 | }) | 125 | }) |
| 122 | .catch(function (err) { | 126 | .catch(function (err) { |
| 123 | - console.error(err.name + ', ' + err.message); | ||
| 124 | - }); | 127 | + _nativeRequestInProgress = false |
| 128 | + console.error(err.name + ', ' + err.message) | ||
| 129 | + }) | ||
| 125 | } else if (oldIOS) { | 130 | } else if (oldIOS) { |
| 126 | - this.disable(); | 131 | + this.disable() |
| 127 | console.warn( | 132 | console.warn( |
| 128 | '\n NoSleep enabled for older iOS devices. This can interrupt\n active or long-running network requests from completing successfully.\n See https://github.com/richtr/NoSleep.js/issues/15 for more details.\n ' | 133 | '\n NoSleep enabled for older iOS devices. This can interrupt\n active or long-running network requests from completing successfully.\n See https://github.com/richtr/NoSleep.js/issues/15 for more details.\n ' |
| 129 | - ); | 134 | + ) |
| 130 | this.noSleepTimer = window.setInterval(function () { | 135 | this.noSleepTimer = window.setInterval(function () { |
| 131 | if (!document.hidden) { | 136 | if (!document.hidden) { |
| 132 | - window.location.href = window.location.href.split('#')[0]; | ||
| 133 | - window.setTimeout(window.stop, 0); | 137 | + window.location.href = window.location.href.split('#')[0] |
| 138 | + window.setTimeout(window.stop, 0) | ||
| 134 | } | 139 | } |
| 135 | - }, 15000); | 140 | + }, 15000) |
| 136 | } else { | 141 | } else { |
| 137 | - this.noSleepVideo.play(); | 142 | + this.noSleepVideo.play() |
| 138 | } | 143 | } |
| 139 | }, | 144 | }, |
| 140 | }, | 145 | }, |
| @@ -142,37 +147,84 @@ var NoSleep = (function () { | @@ -142,37 +147,84 @@ var NoSleep = (function () { | ||
| 142 | key: 'disable', | 147 | key: 'disable', |
| 143 | value: function disable() { | 148 | value: function disable() { |
| 144 | if (nativeWakeLock) { | 149 | if (nativeWakeLock) { |
| 145 | - if(this._wakeLock != null) { | ||
| 146 | - this._wakeLock.release(); | 150 | + if (this._wakeLock != null) { |
| 151 | + _releasedNative = true | ||
| 152 | + this._wakeLock.release() | ||
| 147 | } | 153 | } |
| 148 | 154 | ||
| 149 | - this._wakeLock = null; | 155 | + this._wakeLock = null |
| 150 | } else if (oldIOS) { | 156 | } else if (oldIOS) { |
| 151 | if (this.noSleepTimer) { | 157 | if (this.noSleepTimer) { |
| 152 | console.warn( | 158 | console.warn( |
| 153 | '\n NoSleep now disabled for older iOS devices.\n ' | 159 | '\n NoSleep now disabled for older iOS devices.\n ' |
| 154 | - ); | ||
| 155 | - window.clearInterval(this.noSleepTimer); | ||
| 156 | - this.noSleepTimer = null; | 160 | + ) |
| 161 | + window.clearInterval(this.noSleepTimer) | ||
| 162 | + this.noSleepTimer = null | ||
| 157 | } | 163 | } |
| 158 | } else { | 164 | } else { |
| 159 | - this.noSleepVideo.pause(); | 165 | + this.noSleepVideo.pause() |
| 160 | } | 166 | } |
| 161 | }, | 167 | }, |
| 162 | }, | 168 | }, |
| 163 | { | 169 | { |
| 164 | - key: 'isEnabled', | ||
| 165 | - value: function isEnabled() { | ||
| 166 | - if (oldIOS) { | ||
| 167 | - return this.noSleepTimer != null; | 170 | + key: 'enabled', |
| 171 | + value: async function enabled() { | ||
| 172 | + if (nativeWakeLock) { | ||
| 173 | + if (_nativeRequestInProgress == true) { | ||
| 174 | + // Wait until the request is done. | ||
| 175 | + while (true) { | ||
| 176 | + // Wait for 42 milliseconds. | ||
| 177 | + await new Promise((resolve, reject) => setTimeout(resolve, 42)) | ||
| 178 | + if (_nativeRequestInProgress == false) { | ||
| 179 | + break | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + // todo: use WakeLockSentinel.released when that is available (https://developer.mozilla.org/en-US/docs/Web/API/WakeLockSentinel/released) | ||
| 185 | + if (_releasedNative != false) { | ||
| 186 | + return false | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + return true | ||
| 190 | + } else if (oldIOS) { | ||
| 191 | + return this.noSleepTimer != null | ||
| 168 | } else { | 192 | } else { |
| 169 | - return !this.noSleepVideo.paused; | 193 | + if (this.noSleepVideo == undefined) { |
| 194 | + return false | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + return !this.noSleepVideo.paused | ||
| 170 | } | 198 | } |
| 171 | }, | 199 | }, |
| 172 | }, | 200 | }, |
| 173 | - ]); | 201 | + ]) |
| 202 | + | ||
| 203 | + return NoSleep | ||
| 204 | +})() | ||
| 205 | + | ||
| 206 | +var noSleep = new NoSleep() | ||
| 174 | 207 | ||
| 175 | - return NoSleep; | ||
| 176 | -})(); | 208 | +var Wakelock = { |
| 209 | + enabled: async function () { | ||
| 210 | + try { | ||
| 211 | + return noSleep.enabled() | ||
| 212 | + } catch (e) { | ||
| 213 | + return false | ||
| 214 | + } | ||
| 215 | + }, | ||
| 216 | + toggle: async function (enable) { | ||
| 217 | + if (enable) { | ||
| 218 | + noSleep.enable() | ||
| 219 | + } else { | ||
| 220 | + noSleep.disable() | ||
| 221 | + } | ||
| 222 | + }, | ||
| 223 | +} | ||
| 177 | 224 | ||
| 178 | -var Wakelock = new NoSleep(); | 225 | +if (nativeWakeLock != true) { |
| 226 | + // The first non-native call sometimes throws an error, however, | ||
| 227 | + // the error does not leak the try-catch above. Therefore, this | ||
| 228 | + // is an easy fix that realiably works. | ||
| 229 | + Wakelock.enabled() | ||
| 230 | +} |
wakelock_web/lib/src/func.dart
0 → 100644
| 1 | +typedef Func1<A, R> = R Function(A a); |
wakelock_web/lib/src/js_wakelock.dart
0 → 100644
| 1 | +@JS('Wakelock') | ||
| 2 | +library wakelock.js; | ||
| 3 | + | ||
| 4 | +import 'package:js/js.dart'; | ||
| 5 | +import 'package:wakelock_web/src/promise.dart'; | ||
| 6 | + | ||
| 7 | +/// Toggles the JS wakelock. | ||
| 8 | +external toggle(bool enable); | ||
| 9 | + | ||
| 10 | +/// Returns a JS promise of whether the wakelock is enabled or not. | ||
| 11 | +external PromiseJsImpl<bool> enabled(); |
wakelock_web/lib/src/promise.dart
0 → 100644
| 1 | +@JS() | ||
| 2 | +library firebase.es6_interop; | ||
| 3 | + | ||
| 4 | +import 'package:js/js.dart'; | ||
| 5 | +import 'package:wakelock_web/src/func.dart'; | ||
| 6 | + | ||
| 7 | +/// JavaScript promise typing. | ||
| 8 | +@JS('Promise') | ||
| 9 | +class PromiseJsImpl<T> { | ||
| 10 | + /// Promise constructor for JS code. | ||
| 11 | + external PromiseJsImpl(Function resolver); | ||
| 12 | + | ||
| 13 | + /// Attaches callbacks to a JS promise. | ||
| 14 | + external PromiseJsImpl then([Func1 onResolve, Func1 onReject]); | ||
| 15 | +} |
wakelock_web/lib/wakelock_js.dart
deleted
100644 → 0
| 1 | import 'dart:async'; | 1 | import 'dart:async'; |
| 2 | 2 | ||
| 3 | -import 'dart:js'; | ||
| 4 | - | ||
| 5 | -import 'package:flutter/services.dart'; | ||
| 6 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; | 3 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; |
| 7 | import 'package:import_js_library/import_js_library.dart'; | 4 | import 'package:import_js_library/import_js_library.dart'; |
| 8 | - | ||
| 9 | -import 'wakelock_js.dart' as wakelock; | ||
| 10 | - | ||
| 11 | -/// A web implementation of the Wakelock plugin. | ||
| 12 | -class WakelockWebPlugin { | ||
| 13 | - final _isNativeWakelockSupported = | ||
| 14 | - context['navigator'].hasProperty('wakeLock'); | ||
| 15 | - var _enabled = false; | ||
| 16 | - | 5 | +import 'package:js/js.dart'; |
| 6 | +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
| 7 | +import 'package:wakelock_web/src/js_wakelock.dart' as Wakelock; | ||
| 8 | + | ||
| 9 | +/// The web implementation of the [WakelockPlatformInterface]. | ||
| 10 | +/// | ||
| 11 | +/// This class implements the `wakelock` plugin functionality for web. | ||
| 12 | +class WakelockWeb extends WakelockPlatformInterface { | ||
| 13 | + /// Registers [WakelockWeb] as the default instance of the | ||
| 14 | + /// [WakelockPlatformInterface]. | ||
| 17 | static void registerWith(Registrar registrar) { | 15 | static void registerWith(Registrar registrar) { |
| 18 | - final MethodChannel channel = MethodChannel( | ||
| 19 | - 'wakelock', | ||
| 20 | - const StandardMethodCodec(), | ||
| 21 | - registrar.messenger, | ||
| 22 | - ); | ||
| 23 | - | ||
| 24 | - /// Import JS library | ||
| 25 | - importJsLibrary(url: './assets/NoSleep.js', flutterPluginName: 'wakelock'); | 16 | + // Import a version of `NoSleep.js` that was adjusted for the wakelock |
| 17 | + // plugin. | ||
| 18 | + importJsLibrary( | ||
| 19 | + url: 'assets/no_sleep.js', flutterPluginName: 'wakelock_web'); | ||
| 26 | 20 | ||
| 27 | - final pluginInstance = WakelockWebPlugin(); | ||
| 28 | - channel.setMethodCallHandler(pluginInstance.handleMethodCall); | 21 | + WakelockPlatformInterface.instance = WakelockWeb(); |
| 29 | } | 22 | } |
| 30 | 23 | ||
| 31 | - /// Handles method calls over the MethodChannel of this plugin. | ||
| 32 | - /// Note: Check the "federated" architecture for a new way of doing this: | ||
| 33 | - /// https://flutter.dev/go/federated-plugins | ||
| 34 | - Future<dynamic> handleMethodCall(MethodCall call) async { | ||
| 35 | - switch (call.method) { | ||
| 36 | - case 'toggle': | ||
| 37 | - final bool enable = call.arguments['enable']; | ||
| 38 | - return Future.value(_toggle(enable)); | ||
| 39 | - break; | ||
| 40 | - case 'isEnabled': | ||
| 41 | - return Future.value(_isEnabled()); | ||
| 42 | - break; | ||
| 43 | - default: | ||
| 44 | - throw PlatformException( | ||
| 45 | - code: 'Unimplemented', | ||
| 46 | - details: 'wakelock_web for web doesn\'t implement \'${call.method}\'', | ||
| 47 | - ); | ||
| 48 | - } | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - _toggle(bool enable) { | ||
| 52 | - if (enable) { | ||
| 53 | - wakelock.enable(); | ||
| 54 | - } else { | ||
| 55 | - wakelock.disable(); | ||
| 56 | - } | 24 | + @override |
| 25 | + Future<void> toggle({bool enable}) async { | ||
| 26 | + assert(enable != null); | ||
| 57 | 27 | ||
| 58 | - _enabled = enable; | 28 | + Wakelock.toggle(enable); |
| 59 | } | 29 | } |
| 60 | 30 | ||
| 61 | - bool _isEnabled() { | ||
| 62 | - /// If the native WebLock API is supported | ||
| 63 | - /// since these APIs are async in nature | ||
| 64 | - /// Give immediate boolean value based on `_enabled` | ||
| 65 | - if (_isNativeWakelockSupported) { | ||
| 66 | - return _enabled; | ||
| 67 | - } | 31 | + @override |
| 32 | + Future<bool> get enabled async { | ||
| 33 | + final completer = Completer<bool>(); | ||
| 34 | + | ||
| 35 | + Wakelock.enabled().then( | ||
| 36 | + // onResolve | ||
| 37 | + allowInterop((value) { | ||
| 38 | + assert(value is bool); | ||
| 39 | + | ||
| 40 | + completer.complete(value); | ||
| 41 | + }), | ||
| 42 | + // onReject | ||
| 43 | + allowInterop((error) { | ||
| 44 | + completer.completeError(error); | ||
| 45 | + }), | ||
| 46 | + ); | ||
| 68 | 47 | ||
| 69 | - return wakelock.isEnabled(); | 48 | + return completer.future; |
| 70 | } | 49 | } |
| 71 | } | 50 | } |
| 1 | name: wakelock_web | 1 | name: wakelock_web |
| 2 | -description: This plugin allows you to keep the browser devices awake, i.e. prevent the screen from sleeping by toggling the wakelock of the device on or off. | ||
| 3 | -version: 0.1.4+2 | ||
| 4 | -homepage: https://github.com/creativecreatorormaybenot/wakelock | 2 | +description: Web platform implementation of the wakelock_platform_interface for the wakelock plugin. |
| 3 | +version: 0.1.0 | ||
| 4 | +homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_web | ||
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
| 7 | - sdk: ">=2.7.0 <3.0.0" | 7 | + sdk: ">=2.8.0 <3.0.0" |
| 8 | flutter: ">=1.20.0 <2.0.0" | 8 | flutter: ">=1.20.0 <2.0.0" |
| 9 | 9 | ||
| 10 | dependencies: | 10 | dependencies: |
| @@ -12,51 +12,27 @@ dependencies: | @@ -12,51 +12,27 @@ dependencies: | ||
| 12 | sdk: flutter | 12 | sdk: flutter |
| 13 | flutter_web_plugins: | 13 | flutter_web_plugins: |
| 14 | sdk: flutter | 14 | sdk: flutter |
| 15 | + | ||
| 15 | import_js_library: ^1.0.1 | 16 | import_js_library: ^1.0.1 |
| 16 | js: ^0.6.2 | 17 | js: ^0.6.2 |
| 17 | 18 | ||
| 19 | + wakelock_platform_interface: ^0.1.0 | ||
| 20 | + | ||
| 18 | dev_dependencies: | 21 | dev_dependencies: |
| 19 | flutter_test: | 22 | flutter_test: |
| 20 | sdk: flutter | 23 | sdk: flutter |
| 21 | 24 | ||
| 22 | -# For information on the generic Dart part of this file, see the | ||
| 23 | -# following page: https://dart.dev/tools/pub/pubspec | 25 | + pedantic: ^1.9.2 |
| 26 | + | ||
| 27 | + wakelock: | ||
| 28 | + path: ../wakelock | ||
| 24 | 29 | ||
| 25 | -# The following section is specific to Flutter. | ||
| 26 | flutter: | 30 | flutter: |
| 27 | - # This section identifies this Flutter project as a plugin project. | ||
| 28 | - # The 'pluginClass' and Android 'package' identifiers should not ordinarily | ||
| 29 | - # be modified. They are used by the tooling to maintain consistency when | ||
| 30 | - # adding or updating assets for this project. | ||
| 31 | plugin: | 31 | plugin: |
| 32 | platforms: | 32 | platforms: |
| 33 | web: | 33 | web: |
| 34 | - pluginClass: WakelockWebPlugin | 34 | + pluginClass: WakelockWeb |
| 35 | fileName: wakelock_web.dart | 35 | fileName: wakelock_web.dart |
| 36 | 36 | ||
| 37 | - # | ||
| 38 | - # For details regarding assets in packages, see | ||
| 39 | - # https://flutter.dev/assets-and-images/#from-packages | ||
| 40 | - # | ||
| 41 | - # An image asset can refer to one or more resolution-specific "variants", see | ||
| 42 | - # https://flutter.dev/assets-and-images/#resolution-aware. | ||
| 43 | - | ||
| 44 | - # To add custom fonts to your plugin package, add a fonts section here, | ||
| 45 | - # in this "flutter" section. Each entry in this list should have a | ||
| 46 | - # "family" key with the font family name, and a "fonts" key with a | ||
| 47 | - # list giving the asset and other descriptors for the font. For | ||
| 48 | - # example: | ||
| 49 | - # fonts: | ||
| 50 | - # - family: Schyler | ||
| 51 | - # fonts: | ||
| 52 | - # - asset: fonts/Schyler-Regular.ttf | ||
| 53 | - # - asset: fonts/Schyler-Italic.ttf | ||
| 54 | - # style: italic | ||
| 55 | - # - family: Trajan Pro | ||
| 56 | - # fonts: | ||
| 57 | - # - asset: fonts/TrajanPro.ttf | ||
| 58 | - # - asset: fonts/TrajanPro_Bold.ttf | ||
| 59 | - # weight: 700 | ||
| 60 | - # | ||
| 61 | - # For details regarding fonts in packages, see | ||
| 62 | - # https://flutter.dev/custom-fonts/#from-packages | 37 | + assets: |
| 38 | + - assets/no_sleep.js |
wakelock_web/test/wakelock_web_test.dart
0 → 100644
| 1 | +import 'package:flutter_test/flutter_test.dart'; | ||
| 2 | +import 'package:wakelock/wakelock.dart'; | ||
| 3 | +import 'package:wakelock_platform_interface/wakelock_platform_interface.dart'; | ||
| 4 | +import 'package:wakelock_web/wakelock_web.dart'; | ||
| 5 | + | ||
| 6 | +@TestOn('browser') | ||
| 7 | +void main() { | ||
| 8 | + group('$WakelockWeb', () { | ||
| 9 | + setUpAll(() async { | ||
| 10 | + // todo: the web tests do not work as the JS library import does not work. | ||
| 11 | + WakelockPlatformInterface.instance = WakelockWeb(); | ||
| 12 | + }); | ||
| 13 | + | ||
| 14 | + test('$WakelockWeb set as default instance', () { | ||
| 15 | + expect(WakelockPlatformInterface.instance, isA<WakelockWeb>()); | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + test('initially disabled', () async { | ||
| 19 | + expect(Wakelock.enabled, completion(isFalse)); | ||
| 20 | + }); | ||
| 21 | + | ||
| 22 | + test('enable', () async { | ||
| 23 | + await Wakelock.enable(); | ||
| 24 | + expect(Wakelock.enabled, completion(isTrue)); | ||
| 25 | + }); | ||
| 26 | + | ||
| 27 | + test('disable', () async { | ||
| 28 | + await Wakelock.disable(); | ||
| 29 | + expect(Wakelock.enabled, completion(isFalse)); | ||
| 30 | + }); | ||
| 31 | + | ||
| 32 | + test('toggle', () async { | ||
| 33 | + await Wakelock.toggle(enable: true); | ||
| 34 | + expect(Wakelock.enabled, completion(isTrue)); | ||
| 35 | + | ||
| 36 | + await Wakelock.toggle(enable: false); | ||
| 37 | + expect(Wakelock.enabled, completion(isFalse)); | ||
| 38 | + }); | ||
| 39 | + }); | ||
| 40 | +} |
-
Please register or login to post a comment