Skip to content
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

Screen Brightness #77

Closed
xzilja opened this issue Dec 18, 2020 · 1 comment
Closed

Screen Brightness #77

xzilja opened this issue Dec 18, 2020 · 1 comment

Comments

@xzilja
Copy link
Member

xzilja commented Dec 18, 2020

Plugin Request

Name: brightness
Package: @capacitor-community/brightness

Platform(s)

iOS and Android

Existing Solutions

I was able to implement simple one for iOS, not sure if it's the correct way to achieve this however (that Dispatch.main code).

import Capacitor

@objc(Brightness)
public class Brightness: CAPPlugin {
  @objc func get(_ call: CAPPluginCall) {
    call.success([
        "brightness": UIScreen.main.brightness
    ])
  }
    
  @objc func set(_ call: CAPPluginCall) {
    let brightness = call.getFloat("brightness", 1.0)
    DispatchQueue.main.async {
      UIScreen.main.brightness = CGFloat(brightness!)
      call.success()
    }
  }
}

Description

Allow developers to get and set screen brightness

@xzilja xzilja changed the title Get/Set screen brightness Screen Brightness Dec 18, 2020
@robingenz
Copy link
Member

There is a plugin now: https://github.com/capacitor-community/screen-brightness

@xzilja xzilja closed this as completed Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants