Skip to content

Fix SPM integration #95

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon (v25.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "ArrayInDataClass")

Expand Down Expand Up @@ -44,6 +44,36 @@ class WakelockPlusFlutterError (
override val message: String? = null,
val details: Any? = null
) : Throwable()
private fun deepEqualsWakelockPlusMessages(a: Any?, b: Any?): Boolean {
if (a is ByteArray && b is ByteArray) {
return a.contentEquals(b)
}
if (a is IntArray && b is IntArray) {
return a.contentEquals(b)
}
if (a is LongArray && b is LongArray) {
return a.contentEquals(b)
}
if (a is DoubleArray && b is DoubleArray) {
return a.contentEquals(b)
}
if (a is Array<*> && b is Array<*>) {
return a.size == b.size &&
a.indices.all{ deepEqualsWakelockPlusMessages(a[it], b[it]) }
}
if (a is List<*> && b is List<*>) {
return a.size == b.size &&
a.indices.all{ deepEqualsWakelockPlusMessages(a[it], b[it]) }
}
if (a is Map<*, *> && b is Map<*, *>) {
return a.size == b.size && a.all {
(b as Map<Any?, Any?>).containsKey(it.key) &&
deepEqualsWakelockPlusMessages(it.value, b[it.key])
}
}
return a == b
}


/**
* Message for toggling the wakelock on the platform side.
Expand All @@ -65,6 +95,16 @@ data class ToggleMessage (
enable,
)
}
override fun equals(other: Any?): Boolean {
if (other !is ToggleMessage) {
return false
}
if (this === other) {
return true
}
return deepEqualsWakelockPlusMessages(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}

/**
Expand All @@ -87,6 +127,16 @@ data class IsEnabledMessage (
enabled,
)
}
override fun equals(other: Any?): Boolean {
if (other !is IsEnabledMessage) {
return false
}
if (this === other) {
return true
}
return deepEqualsWakelockPlusMessages(toList(), other.toList()) }

override fun hashCode(): Int = toList().hashCode()
}
private open class WakelockPlusMessagesPigeonCodec : StandardMessageCodec() {
override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? {
Expand Down
8 changes: 4 additions & 4 deletions wakelock_plus/example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
wakelock_plus: 373cfe59b235a6dd5837d0fb88791d2f13a90d56
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
wakelock_plus: e29112ab3ef0b318e58cfa5c32326458be66b556

PODFILE CHECKSUM: beab77b38961de946f08660e554f80ac174dc842

COCOAPODS: 1.16.1
COCOAPODS: 1.16.2
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
1 change: 1 addition & 0 deletions wakelock_plus/ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ profile

DerivedData/
build/
.build/
GeneratedPluginRegistrant.h
GeneratedPluginRegistrant.m

Expand Down
2 changes: 1 addition & 1 deletion wakelock_plus/ios/wakelock_plus.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Plugin that allows you to keep the device screen awake, i.e. prevent the screen
s.source_files = 'wakelock_plus/Sources/wakelock_plus/**/*.{h,m}'
s.public_header_files = 'wakelock_plus/Sources/wakelock_plus/include/**/*.h'
s.dependency 'Flutter'
s.platform = :ios, '11.0'
s.platform = :ios, '12.0'

# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
Expand Down
2 changes: 1 addition & 1 deletion wakelock_plus/ios/wakelock_plus/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
name: "wakelock_plus",
dependencies: [],
resources: [
.process("Resources")
.process("PrivacyInfo.xcprivacy"),
],
cSettings: [
.headerSearchPath("include/wakelock_plus")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by suyao on 2021/12/17.
//

#import "UIApplication+idleTimerLock.h"
#import "./include/wakelock_plus/UIApplication+idleTimerLock.h"
#import <objc/runtime.h>

static NSString *idleTimerLockKey = @"idleTimerLockKey";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#import "WakelockPlusPlugin.h"
#import "messages.g.h"
#import "UIApplication+idleTimerLock.h"
#import "./include/wakelock_plus/WakelockPlusPlugin.h"
#import "./include/wakelock_plus/messages.g.h"
#import "./include/wakelock_plus/UIApplication+idleTimerLock.h"

@interface WakelockPlusPlugin () <WAKELOCKPLUSWakelockPlusApi>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon (v25.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon (v25.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import "./include/wakelock_plus/messages.g.h"
Expand Down
6 changes: 3 additions & 3 deletions wakelock_plus/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ dependencies:

# Windows dependencies
# win32 is compatible across v5 for Win32 only (not COM)
win32: ">=5.5.1 <6.0.0"
win32: ">=5.6.1 <6.0.0"

# Linux dependencies
dbus: ^0.7.10
dbus: ^0.7.11
package_info_plus: ">=6.0.0 <9.0.0"

# Web dependencies
Expand All @@ -32,7 +32,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
pigeon: ^22.7.0 # dart run pigeon --input "pigeons/messages.dart"
pigeon: ^25.3.0 # dart run pigeon --input "pigeons/messages.dart"

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
96 changes: 73 additions & 23 deletions wakelock_plus_platform_interface/lib/messages.g.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon (v25.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers

Expand All @@ -15,8 +15,7 @@ PlatformException _createConnectionError(String channelName) {
);
}

List<Object?> wrapResponse(
{Object? result, PlatformException? error, bool empty = false}) {
List<Object?> wrapResponse({Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
Expand All @@ -25,6 +24,20 @@ List<Object?> wrapResponse(
}
return <Object?>[error.code, error.message, error.details];
}
bool _deepEquals(Object? a, Object? b) {
if (a is List && b is List) {
return a.length == b.length &&
a.indexed
.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
}
if (a is Map && b is Map) {
return a.length == b.length && a.entries.every((MapEntry<Object?, Object?> entry) =>
(b as Map<Object?, Object?>).containsKey(entry.key) &&
_deepEquals(entry.value, b[entry.key]));
}
return a == b;
}


/// Message for toggling the wakelock on the platform side.
class ToggleMessage {
Expand All @@ -34,18 +47,38 @@ class ToggleMessage {

bool? enable;

Object encode() {
List<Object?> _toList() {
return <Object?>[
enable,
];
}

Object encode() {
return _toList(); }

static ToggleMessage decode(Object result) {
result as List<Object?>;
return ToggleMessage(
enable: result[0] as bool?,
);
}

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) {
if (other is! ToggleMessage || other.runtimeType != runtimeType) {
return false;
}
if (identical(this, other)) {
return true;
}
return _deepEquals(encode(), other.encode());
}

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => Object.hashAll(_toList())
;
}

/// Message for reporting the wakelock state from the platform side.
Expand All @@ -56,31 +89,52 @@ class IsEnabledMessage {

bool? enabled;

Object encode() {
List<Object?> _toList() {
return <Object?>[
enabled,
];
}

Object encode() {
return _toList(); }

static IsEnabledMessage decode(Object result) {
result as List<Object?>;
return IsEnabledMessage(
enabled: result[0] as bool?,
);
}

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
bool operator ==(Object other) {
if (other is! IsEnabledMessage || other.runtimeType != runtimeType) {
return false;
}
if (identical(this, other)) {
return true;
}
return _deepEquals(encode(), other.encode());
}

@override
// ignore: avoid_equals_and_hash_code_on_mutable_classes
int get hashCode => Object.hashAll(_toList())
;
}


class _PigeonCodec extends StandardMessageCodec {
const _PigeonCodec();
@override
void writeValue(WriteBuffer buffer, Object? value) {
if (value is int) {
buffer.putUint8(4);
buffer.putInt64(value);
} else if (value is ToggleMessage) {
} else if (value is ToggleMessage) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else if (value is IsEnabledMessage) {
} else if (value is IsEnabledMessage) {
buffer.putUint8(130);
writeValue(buffer, value.encode());
} else {
Expand All @@ -91,9 +145,9 @@ class _PigeonCodec extends StandardMessageCodec {
@override
Object? readValueOfType(int type, ReadBuffer buffer) {
switch (type) {
case 129:
case 129:
return ToggleMessage.decode(readValue(buffer)!);
case 130:
case 130:
return IsEnabledMessage.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
Expand All @@ -105,28 +159,25 @@ class WakelockPlusApi {
/// Constructor for [WakelockPlusApi]. The [binaryMessenger] named argument is
/// available for dependency injection. If it is left null, the default
/// BinaryMessenger will be used which routes to the host platform.
WakelockPlusApi(
{BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
WakelockPlusApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
: pigeonVar_binaryMessenger = binaryMessenger,
pigeonVar_messageChannelSuffix =
messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
final BinaryMessenger? pigeonVar_binaryMessenger;

static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();

final String pigeonVar_messageChannelSuffix;

Future<void> toggle(ToggleMessage msg) async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
final String pigeonVar_channelName = 'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.toggle$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[msg]);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(<Object?>[msg]) as List<Object?>?;
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
Expand All @@ -141,16 +192,15 @@ class WakelockPlusApi {
}

Future<IsEnabledMessage> isEnabled() async {
final String pigeonVar_channelName =
'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel =
BasicMessageChannel<Object?>(
final String pigeonVar_channelName = 'dev.flutter.pigeon.wakelock_plus_platform_interface.WakelockPlusApi.isEnabled$pigeonVar_messageChannelSuffix';
final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
pigeonVar_channelName,
pigeonChannelCodec,
binaryMessenger: pigeonVar_binaryMessenger,
);
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
final List<Object?>? pigeonVar_replyList =
await pigeonVar_channel.send(null) as List<Object?>?;
await pigeonVar_sendFuture as List<Object?>?;
if (pigeonVar_replyList == null) {
throw _createConnectionError(pigeonVar_channelName);
} else if (pigeonVar_replyList.length > 1) {
Expand Down
Loading
Loading