You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
76 lines
2.0 KiB
![]()
2 years ago
|
//
|
||
|
// DeviceSwitchover.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by ecell on 2023/7/7.
|
||
|
// Copyright © 2023 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "DeviceSwitchover.h"
|
||
|
|
||
|
@interface DeviceSwitchover ()<YBPopupMenuDelegate>
|
||
|
|
||
|
/// 是否有添加
|
||
|
@property (nonatomic ,assign) BOOL isAdd;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation DeviceSwitchover
|
||
|
|
||
|
+ (instancetype)sharedManager
|
||
|
{
|
||
|
static dispatch_once_t onceToken;
|
||
|
static DeviceSwitchover *apitance;
|
||
|
dispatch_once(&onceToken, ^{
|
||
|
apitance = [[DeviceSwitchover alloc] init];
|
||
|
});
|
||
|
return apitance;
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)showMenuViewWithAdd:(BOOL)add
|
||
|
{
|
||
|
self.isAdd = add;
|
||
|
CGPoint point = CGPointMake(SCREEN_WIDTH - 30, iPhoneX_NavHeight-5);
|
||
|
NSMutableArray *titles = [NSMutableArray new];
|
||
|
NSMutableArray *icons = [NSMutableArray new];
|
||
|
// 显示切换列表
|
||
|
|
||
|
//添加 --- 添加设备
|
||
|
if(add)
|
||
|
{
|
||
|
[titles addObject:@"添加设备"];
|
||
|
[icons addObject:ImageName_(@"home_icon_add_watch")];
|
||
|
}
|
||
|
if(APIManager.sharedManager.deviceList.count != 0)
|
||
|
{
|
||
|
for (DeviceModel *model in APIManager.sharedManager.deviceList)
|
||
|
{
|
||
|
if (model.image.length <= 0)
|
||
|
[icons addObject:model.sex == 2 ? @"icon_girl_head_portrait" : @"icon_boy_head_portrait"];
|
||
|
else
|
||
|
[icons addObject:model.image];
|
||
|
[titles addObject:model.name];
|
||
|
}
|
||
|
|
||
|
}
|
||
|
[YBPopupMenu showAtPoint:point titles:titles icons:nil menuWidth:120*(SCREEN_WIDTH/320) otherSettings:^(YBPopupMenu *popupMenu) {
|
||
|
popupMenu.textColor = KKTextBlackColor;
|
||
|
popupMenu.fontSize = 15;
|
||
|
popupMenu.cornerRadius = 4.0f;
|
||
|
popupMenu.dismissOnSelected = YES;
|
||
|
popupMenu.delegate = self;
|
||
|
popupMenu.offset = 5;
|
||
|
popupMenu.type = YBPopupMenuTypeDefault;
|
||
|
}];
|
||
|
}
|
||
|
|
||
|
#pragma mark - YBPopupMenuDelegate 代理方法
|
||
|
- (void)ybPopupMenuDidSelectedAtIndex:(NSInteger)index ybPopupMenu:(YBPopupMenu *)ybPopupMenu {
|
||
|
[ybPopupMenu dismiss];
|
||
|
self.switchDevice(index);
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|