//
//  ICBatteryCareListHeaderViewCell.m
//  superCleaner
//
//  Created by Mazy on 2020/7/31.
//  Copyright © 2020 Mazy. All rights reserved.
//

#import "ICBatteryCareListHeaderViewCell.h"

@implementation ICBatteryCareListHeaderViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    [UIDevice currentDevice].batteryMonitoringEnabled = true;
    
    float batteryLevel = [[UIDevice currentDevice] batteryLevel];
    self.batteryLevelLabel.text = [NSString stringWithFormat:@"%.0f%%", (CGFloat)batteryLevel * 100];
    self.chargeIconView.hidden = ([UIDevice currentDevice].batteryState != UIDeviceBatteryStateCharging);
    self.progressView.value = batteryLevel;
    [self.progressView setNeedsDisplay];
    
    NSLog(@"获取当前电池电量0.0~1.0 : %f", batteryLevel);
    
    /// 获取电池当前的状态,共有4种状态
    ///  - .charging (plugged in, less than 100% - 充电中)
    ///  - .full (plugged in, at 100% - 满电)
    ///  - .unplugged (on battery, discharging - 未充电,放电中)
    ///  - .unknown (isBatteryMonitoringEnabled is false)
    /// - Returns: UIDeviceBatteryState
    //    [UIDevice currentDevice].batteryMonitoringEnabled = true;
    NSLog(@"获取电池当前的状态,共有4种状态 : %ld", (long)[UIDevice currentDevice].batteryState);
    //    [UIDevice currentDevice].batteryMonitoringEnabled = true;

    self.firstTipLabel.text = ICLocalized(@"PowerSavingTips");
    self.secondTipLabel.text = ICLocalized(@"ExtendBatteryLife");
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
