8000 Integrate wakelock_windows into wakelock by creativecreatorormaybenot · Pull Request #101 · creativecreatorormaybenot/wakelock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

Integrate wakelock_windows into wakelock #101

Merged
merged 2 commits into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Wakelock [![GitHub stars](https://img.shields.io/github/stars/creativecreatorormaybenot/wakelock.svg)](https://github.com/creativecreatorormaybenot/wakelock) [![Pub version](https://img.shields.io/pub/v/wakelock.svg)](https://pub.dev/packages/wakelock) [![Twitter Follow](https://img.shields.io/twitter/follow/creativemaybeno?label=Follow&style=social)](https://twitter.com/creativemaybeno)

Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping.
Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e. prevent the screen
from sleeping.

## Supported platforms

Expand All @@ -10,7 +11,7 @@ Wakelock is Flutter plugin that allows you to keep the device screen awake, i.e.
| iOS | ✅ |
| Web | ✅ |
| macOS | ✅ |
| Windows | planned |
| Windows | |
| Linux | planned |

## Getting started
Expand All @@ -32,6 +33,7 @@ The packages in this repo are the following:
| [`wakelock_macos`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_macos) | macOS implementation |
| [`wakelock_platform_interface`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_platform_interface) | Basic API definition & message handling |
| [`wakelock_web`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_web) | Web implementation |
| [`wakelock_web`](https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock_windows) | Windows implementation |

## Contributing

Expand All @@ -40,7 +42,8 @@ If you want to contribute to this plugin, follow the [contributing guide](https:
## Origin

Originally, this plugin was based on [`screen`](https://pub.dev/packages/screen).
Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance by the author of the `screen` plugin.
Specifically, the wakelock functionality was extracted into this plugin due to lack of maintenance
by the author of the `screen` plugin.

Today, the `wakelock` plugin has been completely refreshed (using latest Flutter standards and platform integration) with added support
for web & macOS.
Today, the `wakelock` plugin has been completely refreshed (using latest Flutter standards and
platform integration) with added support for web, Windows, & macOS.
4 changes: 3 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ include: package:pedantic/analysis_options.yaml

linter:
rules:
- public_member_api_docs
public_member_api_docs: true
# Ignoring unsafe_html as we need to import a JS script in wakelock_web and because of https://github.com/dart-lang/sdk/issues/45230.
unsafe_html: false
4 changes: 4 additions & 0 deletions wakelock/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

* Added Windows support 🚀

## 0.4.0

* Bumped to stable null safety release.
Expand Down
2 changes: 1 addition & 1 deletion wakelock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Essentially, this allows you to keep the device awake, i.e. prevent the device f
| iOS | ✅ |
| Web | ✅ |
| macOS | ✅ |
| Windows | planned |
| Windows | |
| Linux | planned |

## Usage
Expand Down
4 changes: 2 additions & 2 deletions wakelock/ios/wakelock.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.
DESC
s.homepage = 'http://example.com'
s.license = { :file => '../LICENSE' }
Expand Down
42 changes: 28 additions & 14 deletions wakelock/lib/wakelock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:wakelock_macos/wakelock_macos.dart';
import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
import 'package:wakelock_windows/wakelock_windows.dart';

/// The [WakelockPlatformInterface] that is used by [Wakelock].
///
Expand All @@ -12,20 +13,33 @@ import 'package:wakelock_platform_interface/wakelock_platform_interface.dart';
/// test the `pigeon` method channel implementation. Therefore, we want to
/// override this in tests that run on macOS (where there is no actual device).
@visibleForTesting
var wakelockPlatformInstance = !kIsWeb &&
// Assigning the macOS platform instance like this is not optimal.
// Ideally, we would use the default method channel instance on macOS,
// however, it is not yet entirely clear how to integrate with pigeon.
// This should just work fine and the io reference should be tree shaken
// on web.
Platform.isMacOS
? WakelockMacOS()
// This does not feel like the correct way to assign the Windows
// implementation, however, the platform channels do not have to be used
// thanks to the win32 package. See https://github.com/flutter/flutter/issues/52267.
// : (!kIsWeb && Platform.isWindows)
// ? WakelockWindows()
: WakelockPlatformInterface.instance;
var wakelockPlatformInstance = _defaultPlatformInstance;

/// Workaround for configuring platform instances until https://github.com/flutter/flutter/issues/52267
/// arrives on stable.
WakelockPlatformInterface get _defaultPlatformInstance {
// We want to return early on web as the platform checks are unsupported on
// web.
if (kIsWeb) return WakelockPlatformInterface.instance;

if (Platform.isMacOS) {
// Assigning the macOS platform instance like this is not optimal.
// Ideally, we would use the default method channel instance on macOS,
// however, it is not yet entirely clear how to integrate with pigeon.
// This should just work fine and the io reference should be tree shaken
// on web.
return WakelockMacOS();
}

if (Platform.isWindows) {
// This does not feel like the correct way to assign the Windows
// implementation, however, the platform channels do not have to be used
// thanks to the win32 package. See https://github.com/flutter/flutter/issues/52267.
return WakelockWindows();
}

return WakelockPlatformInterface.instance;
}

/// Class providing all wakelock functionality using static members.
///
Expand Down
12 changes: 6 additions & 6 deletions wakelock/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: wakelock
description: >-2
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on
Android, iOS, macOS, Windows, and web.
version: 0.4.0
version: 0.5.0
homepage: https://github.com/creativecreatorormaybenot/wakelock/tree/master/wakelock

environment:
sdk: '>=2.12.0-259.9.beta <3.0.0'
flutter: '>=1.24.0-0'
sdk: '>=2.12.0 <3.0.0'
flutter: '>=2.0.0'

dependencies:
flutter:
Expand All @@ -16,7 +16,7 @@ dependencies:
meta: ^1.2.0

wakelock_macos: ^0.1.0
# wakelock_windows: ^0.1.0
wakelock_windows: ^0.1.0
wakelock_platform_interface: ^0.2.0
wakelock_web: ^0.2.0

Expand All @@ -37,7 +37,7 @@ flutter:
pluginClass: WakelockPlugin
macos:
default_package: wakelock_macos
# windows:
# default_package: wakelock_windows
windows:
default_package: wakelock_windows
web:
default_package: wakelock_web
4 changes: 2 additions & 2 deletions wakelock_macos/macos/wakelock_macos.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Pod::Spec.new do |s|
s.name = 'wakelock_macos'
s.version = '0.0.1'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.'
s.summary = 'Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.'
s.description = <<-DESC
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, and web.
Plugin that allows you to keep the device screen awake, i.e. prevent the screen from sleeping on Android, iOS, macOS, Windows, and web.
DESC
s.homepage = 'https://github.com/creativecreatorormaybenot/wakelock/tree/master/packages/wakelock_macos'
s.license = { :type => 'BSD', :file => '../LICENSE' }
Expand Down
0