fix: Récupérer l'opération active depuis la table operations
- Corrige l'erreur SQL 'Unknown column fk_operation in users' - L'opération active est récupérée depuis operations.chk_active = 1 - Jointure avec users pour filtrer par entité de l'admin créateur - Query: SELECT o.id FROM operations o INNER JOIN users u ON u.fk_entite = o.fk_entite WHERE u.id = ? AND o.chk_active = 1
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface FPPBatteryPlusPlugin : NSObject <FlutterPlugin>
|
||||
@end
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import "FPPBatteryPlusPlugin.h"
|
||||
|
||||
@interface FPPBatteryPlusPlugin () <FlutterStreamHandler>
|
||||
@end
|
||||
|
||||
@implementation FPPBatteryPlusPlugin {
|
||||
FlutterEventSink _eventSink;
|
||||
}
|
||||
|
||||
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
|
||||
FPPBatteryPlusPlugin *instance = [[FPPBatteryPlusPlugin alloc] init];
|
||||
|
||||
FlutterMethodChannel *channel = [FlutterMethodChannel
|
||||
methodChannelWithName:@"dev.fluttercommunity.plus/battery"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
|
||||
[registrar addMethodCallDelegate:instance channel:channel];
|
||||
FlutterEventChannel *chargingChannel = [FlutterEventChannel
|
||||
eventChannelWithName:@"dev.fluttercommunity.plus/charging"
|
||||
binaryMessenger:[registrar messenger]];
|
||||
[chargingChannel setStreamHandler:instance];
|
||||
}
|
||||
|
||||
- (void)handleMethodCall:(FlutterMethodCall *)call
|
||||
result:(FlutterResult)result {
|
||||
if ([@"getBatteryLevel" isEqualToString:call.method]) {
|
||||
int batteryLevel = [self getBatteryLevel];
|
||||
if (batteryLevel == -1) {
|
||||
result([FlutterError errorWithCode:@"UNAVAILABLE"
|
||||
message:@"Battery info unavailable"
|
||||
details:nil]);
|
||||
} else {
|
||||
result(@(batteryLevel));
|
||||
}
|
||||
} else if ([@"getBatteryState" isEqualToString:call.method]) {
|
||||
NSString *state = [self getBatteryState];
|
||||
if (state) {
|
||||
result(state);
|
||||
} else {
|
||||
result([FlutterError errorWithCode:@"UNAVAILABLE"
|
||||
message:@"Charging status unavailable"
|
||||
details:nil]);
|
||||
}
|
||||
} else if ([@"isInBatterySaveMode" isEqualToString:call.method]) {
|
||||
result(@([[NSProcessInfo processInfo] isLowPowerModeEnabled]));
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onBatteryStateDidChange:(NSNotification *)notification {
|
||||
[self sendBatteryStateEvent];
|
||||
}
|
||||
|
||||
- (void)sendBatteryStateEvent {
|
||||
if (!_eventSink)
|
||||
return;
|
||||
NSString *state = [self getBatteryState];
|
||||
if (state) {
|
||||
_eventSink(state);
|
||||
} else {
|
||||
_eventSink([FlutterError errorWithCode:@"UNAVAILABLE"
|
||||
message:@"Charging status unavailable"
|
||||
details:nil]);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)getBatteryState {
|
||||
UIDevice *device = UIDevice.currentDevice;
|
||||
device.batteryMonitoringEnabled = YES;
|
||||
UIDeviceBatteryState state = [device batteryState];
|
||||
switch (state) {
|
||||
case UIDeviceBatteryStateUnknown:
|
||||
return @"unknown";
|
||||
case UIDeviceBatteryStateFull:
|
||||
return @"full";
|
||||
case UIDeviceBatteryStateCharging:
|
||||
return @"charging";
|
||||
case UIDeviceBatteryStateUnplugged:
|
||||
return @"discharging";
|
||||
default:
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (int)getBatteryLevel {
|
||||
UIDevice *device = UIDevice.currentDevice;
|
||||
device.batteryMonitoringEnabled = YES;
|
||||
if (device.batteryState == UIDeviceBatteryStateUnknown) {
|
||||
return -1;
|
||||
} else {
|
||||
return ((int)(device.batteryLevel * 100));
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark FlutterStreamHandler impl
|
||||
|
||||
- (FlutterError *)onListenWithArguments:(id)arguments
|
||||
eventSink:(FlutterEventSink)eventSink {
|
||||
_eventSink = eventSink;
|
||||
[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
|
||||
[self sendBatteryStateEvent];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(onBatteryStateDidChange:)
|
||||
name:UIDeviceBatteryStateDidChangeNotification
|
||||
object:nil];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (FlutterError *)onCancelWithArguments:(id)arguments {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
_eventSink = nil;
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
|
||||
#
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'battery_plus'
|
||||
s.version = '1.0.0'
|
||||
s.summary = 'Flutter plugin for accessing information about the battery_plus.'
|
||||
s.description = <<-DESC
|
||||
A Flutter plugin to access various information about the battery of the device the app is running on.
|
||||
Downloaded by pub (not CocoaPods).
|
||||
DESC
|
||||
s.homepage = 'https://plus.fluttercommunity.dev/'
|
||||
s.license = { :type => 'BSD', :file => '../LICENSE' }
|
||||
s.author = { 'Flutter Community Team' => 'authors@fluttercommunity.dev' }
|
||||
s.source = { :http => 'https://github.com/fluttercommunity/plus_plugins/tree/main/packages/battery_plus' }
|
||||
s.documentation_url = 'https://pub.dev/packages/battery_plus'
|
||||
s.source_files = 'Classes/**/*'
|
||||
s.public_header_files = 'Classes/**/*.h'
|
||||
s.dependency 'Flutter'
|
||||
|
||||
s.platform = :ios, '12.0'
|
||||
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
||||
s.resource_bundles = {'batery_plus_privacy' => ['PrivacyInfo.xcprivacy']}
|
||||
end
|
||||
Reference in New Issue
Block a user