forked from mirrors/linphone-iphone
Delete UIAlertController Extension
This commit is contained in:
parent
c96b7d6002
commit
f3532e7124
3 changed files with 94 additions and 119 deletions
|
|
@ -1,9 +1,21 @@
|
|||
//
|
||||
// CustomAlertController.swift
|
||||
// linphone
|
||||
//
|
||||
// Created by Benoît Martins on 19/12/2022.
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-iphone
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
|
|
@ -85,4 +97,80 @@ class CustomAlertController: UIAlertController {
|
|||
checkBoxText.sizeToFit()
|
||||
}
|
||||
}
|
||||
|
||||
func setBackgroundColor(color: UIColor) {
|
||||
if let bgView = self.view.subviews.first, let groupView = bgView.subviews.first, let contentView = groupView.subviews.first {
|
||||
contentView.backgroundColor = color
|
||||
}
|
||||
}
|
||||
|
||||
func setMaxWidth(alert: UIAlertController) {
|
||||
let widthConstraints = alert.view.constraints.filter({ return $0.firstAttribute == .width })
|
||||
alert.view.removeConstraints(widthConstraints)
|
||||
let newWidth = UIScreen.main.bounds.width * 0.90
|
||||
let widthConstraint = NSLayoutConstraint(item: alert.view,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: nil,
|
||||
attribute: .notAnAttribute,
|
||||
multiplier: 1,
|
||||
constant: newWidth)
|
||||
alert.view.addConstraint(widthConstraint)
|
||||
let firstContainer = alert.view.subviews[0]
|
||||
let constraint = firstContainer.constraints.filter({ return $0.firstAttribute == .width && $0.secondItem == nil })
|
||||
firstContainer.removeConstraints(constraint)
|
||||
alert.view.addConstraint(NSLayoutConstraint(item: firstContainer,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: alert.view,
|
||||
attribute: .width,
|
||||
multiplier: 1.0,
|
||||
constant: 0))
|
||||
let innerBackground = firstContainer.subviews[0]
|
||||
let innerConstraints = innerBackground.constraints.filter({ return $0.firstAttribute == .width && $0.secondItem == nil })
|
||||
innerBackground.removeConstraints(innerConstraints)
|
||||
firstContainer.addConstraint(NSLayoutConstraint(item: innerBackground,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: firstContainer,
|
||||
attribute: .width,
|
||||
multiplier: 1.0,
|
||||
constant: 0))
|
||||
}
|
||||
|
||||
func setTitle(font: UIFont?, color: UIColor?) {
|
||||
guard let title = self.title else { return }
|
||||
let attributeString = NSMutableAttributedString(string: title)
|
||||
|
||||
if let titleFont = font {
|
||||
attributeString.addAttributes([NSAttributedString.Key.font : titleFont],
|
||||
range: NSMakeRange(0, title.count))
|
||||
}
|
||||
|
||||
if let titleColor = color {
|
||||
attributeString.addAttributes([NSAttributedString.Key.foregroundColor : titleColor],
|
||||
range: NSMakeRange(0, title.count))
|
||||
}
|
||||
|
||||
self.setValue(attributeString, forKey: "attributedTitle")
|
||||
}
|
||||
|
||||
func setMessage(font: UIFont?, color: UIColor?) {
|
||||
guard let message = self.message else { return }
|
||||
let attributeString = NSMutableAttributedString(string: message)
|
||||
if let messageFont = font {
|
||||
attributeString.addAttributes([NSAttributedString.Key.font : messageFont],
|
||||
range: NSMakeRange(0, message.count))
|
||||
}
|
||||
|
||||
if let messageColorColor = color {
|
||||
attributeString.addAttributes([NSAttributedString.Key.foregroundColor : messageColorColor],
|
||||
range: NSMakeRange(0, message.count))
|
||||
}
|
||||
self.setValue(attributeString, forKey: "attributedMessage")
|
||||
}
|
||||
|
||||
func setTint(color: UIColor) {
|
||||
self.view.tintColor = color
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-iphone
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
extension UIAlertController {
|
||||
|
||||
//Set background color of UIAlertController
|
||||
func setBackgroundColor(color: UIColor) {
|
||||
if let bgView = self.view.subviews.first, let groupView = bgView.subviews.first, let contentView = groupView.subviews.first {
|
||||
contentView.backgroundColor = color
|
||||
}
|
||||
}
|
||||
|
||||
func setMaxWidth(alert: UIAlertController) {
|
||||
let widthConstraints = alert.view.constraints.filter({ return $0.firstAttribute == .width })
|
||||
alert.view.removeConstraints(widthConstraints)
|
||||
// Here you can enter any width that you want
|
||||
let newWidth = UIScreen.main.bounds.width * 0.90
|
||||
// Adding constraint for alert base view
|
||||
let widthConstraint = NSLayoutConstraint(item: alert.view,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: nil,
|
||||
attribute: .notAnAttribute,
|
||||
multiplier: 1,
|
||||
constant: newWidth)
|
||||
alert.view.addConstraint(widthConstraint)
|
||||
let firstContainer = alert.view.subviews[0]
|
||||
// Finding first child width constraint
|
||||
let constraint = firstContainer.constraints.filter({ return $0.firstAttribute == .width && $0.secondItem == nil })
|
||||
firstContainer.removeConstraints(constraint)
|
||||
// And replacing with new constraint equal to alert.view width constraint that we setup earlier
|
||||
alert.view.addConstraint(NSLayoutConstraint(item: firstContainer,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: alert.view,
|
||||
attribute: .width,
|
||||
multiplier: 1.0,
|
||||
constant: 0))
|
||||
// Same for the second child with width constraint with 998 priority
|
||||
let innerBackground = firstContainer.subviews[0]
|
||||
let innerConstraints = innerBackground.constraints.filter({ return $0.firstAttribute == .width && $0.secondItem == nil })
|
||||
innerBackground.removeConstraints(innerConstraints)
|
||||
firstContainer.addConstraint(NSLayoutConstraint(item: innerBackground,
|
||||
attribute: .width,
|
||||
relatedBy: .equal,
|
||||
toItem: firstContainer,
|
||||
attribute: .width,
|
||||
multiplier: 1.0,
|
||||
constant: 0))
|
||||
}
|
||||
|
||||
//Set title font and title color
|
||||
func setTitle(font: UIFont?, color: UIColor?) {
|
||||
guard let title = self.title else { return }
|
||||
let attributeString = NSMutableAttributedString(string: title)//1
|
||||
|
||||
if let titleFont = font {
|
||||
attributeString.addAttributes([NSAttributedString.Key.font : titleFont],//2
|
||||
range: NSMakeRange(0, title.count))
|
||||
}
|
||||
|
||||
if let titleColor = color {
|
||||
attributeString.addAttributes([NSAttributedString.Key.foregroundColor : titleColor],//3
|
||||
range: NSMakeRange(0, title.count))
|
||||
}
|
||||
|
||||
self.setValue(attributeString, forKey: "attributedTitle")//4
|
||||
}
|
||||
|
||||
//Set message font and message color
|
||||
func setMessage(font: UIFont?, color: UIColor?) {
|
||||
guard let message = self.message else { return }
|
||||
let attributeString = NSMutableAttributedString(string: message)
|
||||
if let messageFont = font {
|
||||
attributeString.addAttributes([NSAttributedString.Key.font : messageFont],
|
||||
range: NSMakeRange(0, message.count))
|
||||
}
|
||||
|
||||
if let messageColorColor = color {
|
||||
attributeString.addAttributes([NSAttributedString.Key.foregroundColor : messageColorColor],
|
||||
range: NSMakeRange(0, message.count))
|
||||
}
|
||||
self.setValue(attributeString, forKey: "attributedMessage")
|
||||
}
|
||||
|
||||
//Set tint color of UIAlertController
|
||||
func setTint(color: UIColor) {
|
||||
self.view.tintColor = color
|
||||
}
|
||||
}
|
||||
|
|
@ -948,7 +948,6 @@
|
|||
D74A44912923BAF90017D063 /* BackActionsNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74A44902923BAF90017D063 /* BackActionsNavigationView.swift */; };
|
||||
D77057F1292E4A340031A970 /* ChatConversationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D77057F0292E4A340031A970 /* ChatConversationViewModel.swift */; };
|
||||
D7A7545029507038005C9D4A /* CustomAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7A7544F29507038005C9D4A /* CustomAlertController.swift */; };
|
||||
D7C6DE7D2947331A00756E03 /* UIAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C6DE7C2947331A00756E03 /* UIAlertController.swift */; };
|
||||
D7C6DE832948CF3100756E03 /* DropDownCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7C6DE812948CF3100756E03 /* DropDownCell.swift */; };
|
||||
D7C6DE842948CF3100756E03 /* DropDownCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D7C6DE822948CF3100756E03 /* DropDownCell.xib */; };
|
||||
EA0007A62356008F003CC6BF /* msgNotificationService.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = EA5F25D9232BD3E200475F2E /* msgNotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
|
|
@ -2187,7 +2186,6 @@
|
|||
D74A44902923BAF90017D063 /* BackActionsNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackActionsNavigationView.swift; sourceTree = "<group>"; };
|
||||
D77057F0292E4A340031A970 /* ChatConversationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatConversationViewModel.swift; sourceTree = "<group>"; };
|
||||
D7A7544F29507038005C9D4A /* CustomAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertController.swift; sourceTree = "<group>"; };
|
||||
D7C6DE7C2947331A00756E03 /* UIAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAlertController.swift; sourceTree = "<group>"; };
|
||||
D7C6DE812948CF3100756E03 /* DropDownCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DropDownCell.swift; sourceTree = "<group>"; };
|
||||
D7C6DE822948CF3100756E03 /* DropDownCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DropDownCell.xib; sourceTree = "<group>"; };
|
||||
DF241FDC6C7431777AB3BD58 /* Pods-msgNotificationContent.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-msgNotificationContent.debug.xcconfig"; path = "Target Support Files/Pods-msgNotificationContent/Pods-msgNotificationContent.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
|
|
@ -3453,7 +3451,6 @@
|
|||
C63F71AF285A24B10066163B /* BackNextNavigationView.swift */,
|
||||
C63F71B0285A24B10066163B /* TimestampUtils.swift */,
|
||||
D74A44902923BAF90017D063 /* BackActionsNavigationView.swift */,
|
||||
D7C6DE7C2947331A00756E03 /* UIAlertController.swift */,
|
||||
D7A7544F29507038005C9D4A /* CustomAlertController.swift */,
|
||||
);
|
||||
path = Util;
|
||||
|
|
@ -5047,7 +5044,6 @@
|
|||
D3ED3E871586291E006C0DE4 /* TabBarView.m in Sources */,
|
||||
617C242A263022690042FB4A /* UIChatContentView.m in Sources */,
|
||||
C63F7261285A24B10066163B /* CallControlButton.swift in Sources */,
|
||||
D7C6DE7D2947331A00756E03 /* UIAlertController.swift in Sources */,
|
||||
D3ED3EA71587334E006C0DE4 /* HistoryListTableView.m in Sources */,
|
||||
C63F7220285A24B10066163B /* TimestampUtils.swift in Sources */,
|
||||
61AEBEBD2191990A00F35E7F /* DevicesListView.m in Sources */,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue