123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // SKChatViewController+more.m
- // SikeyComm
- //
- // Created by 刘振兴 on 2024/1/30.
- // Copyright © 2024 BaH Cy. All rights reserved.
- //
- #import "SKChatViewController+more.h"
- #import "SKChatMembersViewController.h"
- #import "SKChatViewController+permission.h"
- @implementation SKChatViewController (more)
- - (void)initMoreButton {
- if ([self.mSessionModel getSessionType] == 0) {
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"chat_group_members"] style:UIBarButtonItemStylePlain target:self action:@selector(showMembers)];
- } else {
- ChildModel* model = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
- if ([model.device isBind]) {
- UIBarButtonItem* button1 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"chat_mms_call"] style: UIBarButtonItemStylePlain target:self action:@selector(showCall)];
- UIBarButtonItem* button2 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"chat_video"] style: UIBarButtonItemStylePlain target:self action:@selector(showVideo)];
- [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects: button1,button2,nil]];
- }
- }
- }
- - (void)showCall {
- ChildModel* model = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
- if ([EUtil isInForbiddenTime:model.device]) {
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"In.Forbidden.Time.No.Call", nil) preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- }]];
- [self presentViewController:alert animated:YES completion:nil];
- } else {
- NSString* phoneNum = model.phoneNumber;
- if (phoneNum == nil || [phoneNum length] <= 0 ) {
- [EasyTextView showInfoText:NSLocalizedString(@"Not.Bind.Mobile.Number", nil)];//@"当前未绑定手机号"];
- return;
- }
-
- //E164
- NSString* nationCode = [DataManager shared].mSelectChildModel.areaCode;
- phoneNum = [EUtil parsePhoneNumber:phoneNum countryCode:nationCode];
-
- phoneNum = [@"tel://" stringByAppendingString:phoneNum];
- if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:phoneNum]]) {
- [EasyTextView showInfoText:NSLocalizedString(@"Call.With.Wrong.Simulator", nil)];//@"呼叫号码不正确或当前设备不支持"];
- } else {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum] options:@{} completionHandler:^(BOOL success) {
- }];
- }
- }
- }
- - (void)showVideo {
- if ([self checkRecordPermission]) {
- [self onNoRecordRight];
- return;
- }
- @weakify(self);
- UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"SKChat.Video.Title", nil) message:NSLocalizedString(@"SKChat.Video.Content", nil) preferredStyle:UIAlertControllerStyleAlert];
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
- }]];
- [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
- [weak_self showVideoEx];
- }]];
- [self presentViewController:alert animated:YES completion:nil];
- }
- - (void)showVideoEx {
- ChildModel* childModel = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [[VideoManager shared] videoStart:self.mSessionModel.sid ticket:childModel.device.ticket dial:1];
- });
- }
- - (void)showMembers {
- //如果键盘弹起中
- [self.mOperationView resignBoard];
- SKChatMembersViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"SKChatMembersVC"];
- controller.mChildId = [self.mSessionModel getChildId];
- controller.mSessionModel = self.mSessionModel;
- [self pushViewController:controller animated:YES];
- }
- @end
|