美文网首页
微信运动插件iOS

微信运动插件iOS

作者: 曾柏超 | 来源:发表于2018-06-04 06:51 被阅读19次

WeChatHeader.h

//
//  WeChatHeader.h
//  001--WeChatDemo11
//
//  Created by H on 2018/5/18.
//  Copyright © 2018年 H. All rights reserved.
//

#ifndef WeChatHeader_h
#define WeChatHeader_h

// See http://iphonedevwiki.net/index.php/Logos

#import <UIKit/UIKit.h>
#define HKDefaults [NSUserDefaults standardUserDefaults]
#define HKSWITCHKEY @"HKSWITCHKEY"
#define HKTIMEKEY @"HKTIMEKEY"

#define ZBSWITCHKEY @"ZBSWITCHKEY"
#define ZBRUNKEY @"ZBRUNKEY"
//关于界面
@interface MMTableViewInfo
- (long long)numberOfSectionsInTableView:(id)arg1;
@end

@interface WCRedEnvelopesReceiveHomeView
{
    id m_delegate;
    NSDictionary *m_dicBaseInfo;
}
@end


@interface WCPayInfoItem :NSObject
@property(retain, nonatomic) NSString *m_c2cNativeUrl;
@end



@interface CMessageWrap :NSObject
@property(retain, nonatomic) WCPayInfoItem *m_oWCPayInfoItem;
@property(retain, nonatomic) NSString *m_nsFromUsr; 
@end



@interface WCRedEnvelopesControlData :NSObject
@property(retain, nonatomic) CMessageWrap *m_oSelectedMessageWrap;
@property(retain, nonatomic) NSDictionary *m_structDicRedEnvelopesBaseInfo;
@end



@interface WCRedEnvelopesControlLogic
{
    WCRedEnvelopesControlData *m_data;
}
@end

@interface WCRedEnvelopesReceiveControlLogic:WCRedEnvelopesControlLogic

@end


@interface WCBizUtil: NSObject
+ (id)dictionaryWithDecodedComponets:(id)arg1 separator:(id)arg2;
@end






@interface MMServiceCenter
+(id)defaultCenter;
-(id)getService:(Class)arg1;
@end

@interface MMMsgLogicManager
-(id)GetCurrentLogicController;
@end


@interface WeixinContentLogicController
-(id)m_contact;
@end





@interface CContactMgr
-(id)getSelfContact;
@end

@interface CBaseContact
@property(retain, nonatomic) NSString *m_nsHeadImgUrl;
@property(retain, nonatomic) NSString *m_nsUsrName;
@end


@interface CContact :CBaseContact
-(id)getContactDisplayName;

@end

@interface WCPayLogicMgr
- (void)setRealnameReportScene:(unsigned int)arg1;
- (void)checkHongbaoOpenLicense:(id)arg1 acceptCallback:(void(^)())arg2 denyCallback:(void(^)())arg3;
@end



@interface BaseResponse
@property(nonatomic) int ret; // @dynamic ret;
@end

@interface SKBuiltinBuffer_t
@property(retain, nonatomic) NSData *buffer; // @dynamic buffer;
@property(nonatomic) unsigned int iLen; // @dynamic iLen;
@end


@interface HongBaoRes
// Remaining properties
@property(retain, nonatomic) BaseResponse *baseResponse; // @d
@property(retain, nonatomic) SKBuiltinBuffer_t *retText; // @dynamic retText;
@property(nonatomic) int cgiCmdid; // @dynamic cgiCmdid;
@property(retain, nonatomic) NSString *errorMsg; // @dynamic errorMsg;
@property(nonatomic) int errorType; // @dynamic errorType;
@property(retain, nonatomic) NSString *platMsg; // @dynamic platMsg;
@property(nonatomic) int platRet;
@end

@interface WCRedEnvelopesLogicMgr
-(void)OpenRedEnvelopesRequest:(id)dic;
- (void)ReceiverQueryRedEnvelopesRequest:(id)arg1;
- (void)OnWCToHongbaoCommonResponse:(HongBaoRes *)arg1 Request:(id)arg2;
@end









#endif /* WeChatHeader_h */


settingcell.xm

#import"WeChatHeader.h"
#import <UIKit/UIKit.h>


%hook MMTableViewInfo

%new
- (void)textFieldDidChangeValue:(NSNotification *)notification{
    
    UITextField *sender = (UITextField *)[notification object];
    [HKDefaults setValue:sender.text forKey:HKTIMEKEY];
    [HKDefaults synchronize];
}


%new
- (void)zbtextFieldDidChangeValue:(NSNotification *)notification{
    
    UITextField *sender = (UITextField *)[notification object];
    [HKDefaults setValue:sender.text forKey:ZBRUNKEY];
    [HKDefaults synchronize];
}


%new
-(void)zbswitchChang:(UISwitch *)switchView{
    [HKDefaults setBool:switchView.isOn forKey:ZBSWITCHKEY];
    [HKDefaults synchronize];
    [MSHookIvar <UITableView *>(self,"_tableView") reloadData];
}

%new
-(void)switchChang:(UISwitch *)switchView{
    [HKDefaults setBool:switchView.isOn forKey:HKSWITCHKEY];
    [HKDefaults synchronize];
    [MSHookIvar <UITableView *>(self,"_tableView") reloadData];
}



- (void)scrollViewWillBeginDragging:(id)arg1{
    %orig;
    [MSHookIvar <UITableView *>(self,"_tableView") endEditing:YES];
}


//返回高度
- (double)tableView:
(UITableView *)tableView heightForRowAtIndexPath:(id)indexPath{
    //定位设置界面,并且是最后一组
    if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
       && [indexPath section] ==[self numberOfSectionsInTableView:tableView]-1){
        return 44;
        
    }else   if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
                 && [indexPath section] ==[self numberOfSectionsInTableView:tableView]-2){
        return 44;
        
    }
    
    else{
        return %orig;
    }
}


//每一个Cell
- (id)tableView:(UITableView *)tableView cellForRowAtIndexPath:(id)indexPath{
    //定位设置界面,并且是最后一组
    if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
       && [indexPath section] ==[self numberOfSectionsInTableView:tableView]-1){
        
        UITableViewCell * cell = nil;
        if([indexPath row] == 0){
            static NSString * switchCell = @"switchCell";
            cell = [tableView dequeueReusableCellWithIdentifier:switchCell];
            if(!cell){
                cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:nil];
            }
            cell.textLabel.text = @"微信运动";
            //抢红包开关!!
            UISwitch * switchView = [[UISwitch alloc] init];
            switchView.on = [HKDefaults boolForKey:ZBSWITCHKEY];
            [switchView addTarget:self action:@selector(zbswitchChang:) forControlEvents:(UIControlEventValueChanged)];
            cell.accessoryView = switchView;
            cell.imageView.image = [UIImage imageNamed:([HKDefaults boolForKey:HKSWITCHKEY] == 1) ? @"unlocked" : @"locked"];
        }else if([indexPath row] == 1){
            static NSString * waitCell = @"waitCell";
            cell = [tableView dequeueReusableCellWithIdentifier:waitCell];
            if(!cell){
                cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:nil];
            }
            cell.textLabel.text = @"步数";
            UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
            //监听键盘输入
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(zbtextFieldDidChangeValue:) name:UITextFieldTextDidChangeNotification object:textField];
            textField.text = [HKDefaults valueForKey:ZBRUNKEY];
            textField.borderStyle = UITextBorderStyleRoundedRect;
            cell.accessoryView = textField;
            cell.imageView.image = [UIImage imageNamed:@"clock"];
            
        }
        cell.backgroundColor = [UIColor whiteColor];
        return cell;
        
    }else  if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
              && [indexPath section] ==[self numberOfSectionsInTableView:tableView]-2){
        
        UITableViewCell * cell = nil;
        if([indexPath row] == 0){
            static NSString * switchCell = @"switchCell";
            cell = [tableView dequeueReusableCellWithIdentifier:switchCell];
            if(!cell){
                cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:nil];
            }
            cell.textLabel.text = @"自动抢红包";
            //抢红包开关!!
            UISwitch * switchView = [[UISwitch alloc] init];
            switchView.on = [HKDefaults boolForKey:HKSWITCHKEY];
            [switchView addTarget:self action:@selector(switchChang:) forControlEvents:(UIControlEventValueChanged)];
            cell.accessoryView = switchView;
            cell.imageView.image = [UIImage imageNamed:([HKDefaults boolForKey:HKSWITCHKEY] == 1) ? @"unlocked" : @"locked"];
        }else if([indexPath row] == 1){
            static NSString * waitCell = @"waitCell";
            cell = [tableView dequeueReusableCellWithIdentifier:waitCell];
            if(!cell){
                cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:nil];
            }
            cell.textLabel.text = @"等待时间(秒)";
            UITextField * textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];
            //监听键盘输入
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChangeValue:) name:UITextFieldTextDidChangeNotification object:textField];
            textField.text = [HKDefaults valueForKey:HKTIMEKEY];
            textField.borderStyle = UITextBorderStyleRoundedRect;
            cell.accessoryView = textField;
            cell.imageView.image = [UIImage imageNamed:@"clock"];
            
        }
        cell.backgroundColor = [UIColor whiteColor];
        return cell;
        
    }
    
    
    
    else  {
        return %orig;
    }
}





//没组多少行
- (long long)tableView:(UITableView *)tableView numberOfRowsInSection:(long long)section{
    //定位设置界面,并且是最后一个
    
    
    NSLog(@"%d",[self numberOfSectionsInTableView:tableView]);
    
    
    if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
       && section ==[self numberOfSectionsInTableView:tableView]-1){
        NSLog(@"%d",section);
        return 2;
        
    }
    
    if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]
       && section ==[self numberOfSectionsInTableView:tableView]-2){
        NSLog(@"%d",section);
        return 2;
        
    }
    
    
    
    else{
        return %orig;
    }
}
//多少组
- (long long)numberOfSectionsInTableView:(id)arg1{
    UITableView * tableView = MSHookIvar <UITableView *>(self,"_tableView");
    if([tableView.nextResponder.nextResponder isKindOfClass:%c(NewSettingViewController)]){//定位设置界面
        //在原来基础上多搞一组
        return %orig+2;
        
    }else{
        return %orig;
    }
}
%end


@interface NewSettingViewController:UIViewController
@end

%hook NewSettingViewController
%new
-(void)keyboardWillShow:(NSNotification*)note{
    
    UIView * view = self.view;
    CGRect keyBoardRect=[note.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
    view.frame = CGRectMake(0, -keyBoardRect.size.height, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height );
    
}

%new
-(void)keyboardWillHide:(NSNotification*)note{
    UIView * view = self.view;
    view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    
}

- (void)viewDidLoad{
    %orig;
    //监听textField弹出和消失
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}



%end




#import"WeChatHeader.h"
%hook WCDeviceStepObject

- (unsigned int)m7StepCount{
    
    
    
    if([HKDefaults boolForKey:ZBSWITCHKEY]){
        return [[HKDefaults valueForKey:ZBRUNKEY] floatValue];
    }else{
        return %orig;
    }
    
  
}

%end



相关文章

网友评论

      本文标题:微信运动插件iOS

      本文链接:https://www.haomeiwen.com/subject/wqfesftx.html