增加换肤功能

This commit is contained in:
启星
2025-08-14 10:07:49 +08:00
parent f6964c1e89
commit 4f9318d98e
8789 changed files with 978530 additions and 2 deletions

View File

@@ -0,0 +1,91 @@
//
// CGFloat+Extension.swift
// Alamofire
//
// Created by aby on 2022/12/26.
// Copyright © 2022 Tencent. All rights reserved.
//
import Foundation
import UIKit
var kScreenWidth: CGFloat {
UIScreen.main.bounds.width
}
var kScreenHeight: CGFloat {
UIScreen.main.bounds.height
}
public let kDeviceIsiPhoneX : Bool = {
if UIDevice.current.userInterfaceIdiom == .pad {
return false
}
let size = UIScreen.main.bounds.size
let notchValue = Int(size.width/size.height*100)
if notchValue == 216 || notchValue == 46 {
return true
}
return false
}()
public let kDeviceSafeBottomHeight : CGFloat = {
if kDeviceIsiPhoneX {
return 34
}
else {
return 0
}
}()
private var width: CGFloat {
return min(kScreenHeight, kScreenWidth)
}
private var height: CGFloat {
return max(kScreenWidth, kScreenHeight)
}
extension CGFloat {
/// Dimensions in 375 design drawings
///
/// - Returns: Final result scaling result
public func scale375(exceptPad: Bool = true) -> CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
return exceptPad ? self * 1.5 : self * (width / 375.00)
}
return self * (width / 375.00)
}
public func scale375Height(exceptPad: Bool = true) -> CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
return exceptPad ? self * 1.5 : self * (height / 812.00)
}
return self * (height / 812.00)
}
/// iPad proportion adaptation
///
/// - Returns: Final Results
public func fitPad() -> CGFloat {
return UIDevice.current.userInterfaceIdiom == .pad ? self * 1.5 : self
}
}
extension Int {
public func scale375(exceptPad: Bool = true) -> CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
return exceptPad ? CGFloat(self) * 1.5 : CGFloat(self) * (width / 375.00)
}
return CGFloat(self) * (width / 375.00)
}
public func scale375Height(exceptPad: Bool = true) -> CGFloat {
if UIDevice.current.userInterfaceIdiom == .pad {
return exceptPad ? CGFloat(self) * 1.5 : CGFloat(self) * (height / 812.00)
}
return CGFloat(self) * (height / 812.00)
}
public func fitPad() -> CGFloat {
return UIDevice.current.userInterfaceIdiom == .pad ? CGFloat(self) * 1.5 : CGFloat(self)
}
}

View File

@@ -0,0 +1,15 @@
//
// Collection+Extension.swift
// TUIRoomKit
//
// Created by janejntang on 2023/3/21.
// Copyright © 2023 Tencent. All rights reserved.
//
import Foundation
extension Collection {
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}

View File

@@ -0,0 +1,17 @@
//
// File.swift
// TUIRoomKit
//
// Created by janejntang on 2024/4/15.
//
import Foundation
extension Dictionary {
func convertToString() -> String?{
let dicData = try? JSONSerialization.data(withJSONObject: self, options: [])
guard let data = dicData else { return nil }
let str = String(data: data, encoding: String.Encoding.utf8)
return str
}
}

View File

@@ -0,0 +1,26 @@
//
// UIView+Extension.swift
// TUIRoomKit
//
// Created by CY zhao on 2024/5/27.
//
#if USE_OPENCOMBINE
import OpenCombine
import OpenCombineDispatch
import OpenCombineFoundation
#else
import Combine
#endif
extension DispatchQueue {
#if USE_OPENCOMBINE
static var mainQueue: DispatchQueue.OCombine {
return DispatchQueue.main.ocombine
}
#else
static var mainQueue: DispatchQueue {
return DispatchQueue.main
}
#endif
}

View File

@@ -0,0 +1,28 @@
//
// NSObject+Extension.h
// TUIRoomKit
//
// Created by WesleyLei on 2022/9/23.
// Copyright © 2022 Tencent. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
@interface NSObject (CoreExtension)
+ (NSString *)getRoomEngineKey;
+ (NSString *)getRoomInfoKey;
+ (NSString *)getLocalUserInfoKey;
+ (NSString *)getTopViewKey;
+ (NSString *)getBottomViewKey;
+ (NSString *)getUserListControllerKey;
+ (NSString *)getExtensionControllerKey;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,40 @@
//
// NSObject+Extension.m
// TUIRoomKit
//
// Created by WesleyLei on 2022/9/23.
// Copyright © 2022 Tencent. All rights reserved.
//
#import "NSObject+CoreExtension.h"
@implementation NSObject (CoreExtension)
+ (NSString *)getRoomEngineKey {
return @"TUIRoomKit.Room.Engine.Key";
}
+ (NSString *)getRoomInfoKey {
return @"TUIRoomKit.Room.Info.Key";
}
+ (NSString *)getLocalUserInfoKey {
return @"TUIRoomKit.Local.User.Info.Key";
}
+ (NSString *)getTopViewKey {
return @"TUIRoomKit.Top.Menu.View.Key";
}
+ (NSString *)getBottomViewKey {
return @"TUIRoomKit.Bottom.Menu.View.Key";
}
+ (NSString *)getUserListControllerKey {
return @"TUIRoomKit.User.List.Controller.Key";
}
+ (NSString *)getExtensionControllerKey {
return @"TUIRoomKit.Extension.Controller.Key";
}
@end

View File

@@ -0,0 +1,53 @@
//
// UIColor+Style.swift
// TUIRoomKit
//
// Created by aby on 2022/12/27.
// Copyright © 2022 Tencent. All rights reserved.
//
import Foundation
extension UIColor {
public convenience init(_ hex: Int, alpha: CGFloat = 1.0) {
assert(0...0xFFFFFF ~= hex, "The color hex value must between 0 to 0XFFFFFF")
let red = (hex & 0xFF0000) >> 16
let green = (hex & 0x00FF00) >> 8
let blue = (hex & 0x0000FF)
self.init(red: red, green: green, blue: blue, alpha: alpha)
}
public convenience init(red: Int, green: Int, blue: Int, alpha: CGFloat = 1.0) {
self.init(
red: CGFloat(red) / 255.0,
green: CGFloat(green) / 255.0,
blue: CGFloat(blue) / 255.0,
alpha: alpha
)
}
public func trans2Image() -> UIImage {
let rect = CGRect(x: 0, y: 0, width: 1.0, height: 1.0)
UIGraphicsBeginImageContext(rect.size)
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(self.cgColor)
context?.fill(rect)
let theImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return theImage ?? UIImage()
}
}
extension UIView {
func roundedRect(rect:CGRect, byRoundingCorners: UIRectCorner, cornerRadii: CGSize) {
let maskPath = UIBezierPath(roundedRect: rect, byRoundingCorners: byRoundingCorners, cornerRadii: cornerRadii)
let maskLayer = CAShapeLayer()
maskLayer.frame = bounds
maskLayer.path = maskPath.cgPath
self.layer.mask = maskLayer
}
func roundedCircle(rect: CGRect) {
roundedRect(rect: rect, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: bounds.size.width / 2, height: bounds.size.height / 2))
}
}

View File

@@ -0,0 +1,37 @@
//
// String+Extension.swift
// TUIRoomKit
//
// Created by aby on 2022/12/26.
// Copyright © 2022 Tencent. All rights reserved.
//
import Foundation
extension String {
func addIntervalSpace(intervalStr: String, interval: Int) -> String {
var output = ""
enumerated().forEach { index, c in
if (index % interval == 0) && index > 0 {
output += intervalStr
}
output.append(c)
}
return output
}
func convertToDic() -> [String : Any]?{
guard let data = self.data(using: String.Encoding.utf8) else { return nil }
if let dict = try? JSONSerialization.jsonObject(with: data,
options: .mutableContainers) as? [String : Any] {
return dict
}
return nil
}
func isStringOnlyDigits() -> Bool {
let regex = "^[0-9]+$"
let predicate = NSPredicate(format: "SELF MATCHES %@", regex)
return predicate.evaluate(with: self)
}
}

View File

@@ -0,0 +1,18 @@
//
// TimeZone+Extension.swift
// TUIRoomKit
//
// Created by janejntang on 2024/6/24.
//
import Foundation
extension TimeZone {
func getTimeZoneName() -> String {
//todo:
let genericName = self.localizedName(for: .generic, locale: .current)
let shortStandardName = self.localizedName(for: .shortStandard, locale: .current)
let name = "(" + (shortStandardName ?? "") + ")" + (genericName ?? "")
return name
}
}

View File

@@ -0,0 +1,25 @@
//
// UIImage+RTL.swift
// TUIRoomKit
//
// Created by janejntang on 2023/8/31.
//
import Foundation
extension UIImage {
func checkOverturn() -> UIImage? {
if isRTL {
UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale)
guard let bitmap: CGContext = UIGraphicsGetCurrentContext() else { return nil }
guard let cgImage = self.cgImage else { return nil }
bitmap.translateBy(x: self.size.width / 2, y: self.size.height / 2)
bitmap.scaleBy(x: -1.0, y: -1.0)
bitmap.translateBy(x: -self.size.width / 2, y: -self.size.height / 2)
bitmap.draw(cgImage, in: CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height))
let image = UIGraphicsGetImageFromCurrentImageContext()
return image
}
return self
}
}

View File

@@ -0,0 +1,18 @@
//
// UIViewController+Extension.swift
// TUIRoomKit
//
// Created by aby on 2024/6/26.
//
import UIKit
extension UIViewController {
var interfaceOrientation: UIInterfaceOrientation {
if #available(iOS 13.0, *) {
return UIApplication.shared.windows.first?.windowScene?.interfaceOrientation ?? .portrait
} else {
return UIApplication.shared.statusBarOrientation
}
}
}