Skip to content

Commit

Permalink
Cleanup WidgetSDK from most warnings
Browse files Browse the repository at this point in the history
WidgetSDK had a lot of warnings that made further development not pleasent. This PR removes most of them. MOB-2846
  • Loading branch information
rasmustautsglia committed Jan 17, 2024
1 parent 678b1fd commit 0226960
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 157 deletions.
4 changes: 2 additions & 2 deletions GliaWidgets.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5320,7 +5320,7 @@
baseConfigurationReference = F42209821D041DD8881645AA /* Pods-TestingApp.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "";
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TestingApp/TestingApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down Expand Up @@ -5348,7 +5348,7 @@
baseConfigurationReference = 2F4C9EF1991B7981DC24CA98 /* Pods-TestingApp.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = "";
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CODE_SIGN_ENTITLEMENTS = TestingApp/TestingApp.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down
1 change: 0 additions & 1 deletion GliaWidgets/Asset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public enum Asset {
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

public extension Image {
@available(iOS 1.0, tvOS 1.0, watchOS 1.0, *)
@available(OSX, unavailable,
message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
convenience init!(asset: ImageAsset) {
Expand Down
70 changes: 0 additions & 70 deletions GliaWidgets/Public/Glia/Glia.Deprecated.swift
Original file line number Diff line number Diff line change
@@ -1,76 +1,6 @@
import GliaCoreSDK

extension Glia {
/// Deprecated.
@available(*, unavailable, message: "Use configure(with:uiConfig:assetsBuilder:completion:) instead.")
public func configure(
with configuration: Configuration,
queueId: String,
visitorContext: VisitorContext?,
completion: (() -> Void)? = nil
) throws {
try self.configure(
with: configuration,
queueId: queueId,
uiConfig: nil,
completion: completion
)
}

/// Deprecated.
@available(
*,
unavailable,
message: "Use start(_:configuration:queueID:visitorContext:theme:features:sceneProvider:) with Optional<VisitorContext> instead."
)
public func start(
_ engagementKind: EngagementKind,
configuration: Configuration,
queueID: String,
visitorContext: VisitorContext,
theme: Theme = Theme(),
features: Features = .all,
sceneProvider: SceneProvider? = nil
) throws {
try self.start(
engagementKind,
configuration: configuration,
queueID: queueID,
visitorContext: Optional(visitorContext),
theme: theme,
features: features,
sceneProvider: sceneProvider
)
}

/// Deprecated.
@available(
*,
deprecated,
message: "Use start(_:configuration:queueID:theme:features:sceneProvider:) instead."
)
public func start(
_ engagementKind: EngagementKind,
configuration: Configuration,
queueID: String,
visitorContext: VisitorContext?,
theme: Theme = Theme(),
features: Features = .all,
sceneProvider: SceneProvider? = nil
) throws {
if visitorContext != nil {
print("⚠️ visitorContext has been deprecated, please pass visitor context using `Configuration`.")
}
try start(
engagementKind,
configuration: configuration,
queueID: queueID,
theme: theme,
features: features,
sceneProvider: sceneProvider
)
}

/// Deprecated, use `clearVisitorSession(_:)` instead.
@available(
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ extension SecureConversations.TranscriptModel {
// MARK: Handling of file-picker
extension SecureConversations.TranscriptModel {
private func presentMediaPicker() {
let itemSelected = { [weak self] (kind: AttachmentSourceItemKind) -> Void in
let itemSelected = { [weak self] (kind: AttachmentSourceItemKind) in
let media = ObservableValue<MediaPickerEvent>(with: .none)
guard let self = self else { return }
media.addObserver(self) { [weak self] event, _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ extension SecureConversations.WelcomeViewModel {
from originView: UIView,
alertConfiguration: AlertConfiguration
) {
let itemSelected = { (kind: AttachmentSourceItemKind) -> Void in
let itemSelected = { (kind: AttachmentSourceItemKind) in
let media = Command<MediaPickerEvent> { [weak self] event in
guard let self = self else { return }
switch event {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,10 @@ extension CallVisualizer {
)
)

if #available(iOS 13.0, *) {
let windows = environment.uiApplication.windows()
interfaceOrientation = windows.first(where: {
$0.isKeyWindow
})?.windowScene?.interfaceOrientation ?? .portrait
} else {
interfaceOrientation = environment.uiApplication.statusBarOrientation()
}
let windows = environment.uiApplication.windows()
interfaceOrientation = windows.first(where: {
$0.isKeyWindow
})?.windowScene?.interfaceOrientation ?? .portrait

connectOperatorSize = .init(size: .normal, animated: true)
operatorImageVisible = false
Expand Down Expand Up @@ -323,14 +319,10 @@ private extension CallVisualizer.VideoCallViewModel {
}

func handleOrientationChange() {
if #available(iOS 13.0, *) {
let windows = environment.uiApplication.windows()
interfaceOrientation = windows.first(where: {
$0.isKeyWindow
})?.windowScene?.interfaceOrientation ?? .portrait
} else {
interfaceOrientation = environment.uiApplication.statusBarOrientation()
}
let windows = environment.uiApplication.windows()
interfaceOrientation = windows.first(where: {
$0.isKeyWindow
})?.windowScene?.interfaceOrientation ?? .portrait
}

func toggleVideo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ extension ChatCoordinator {
isCustomCardSupported: viewFactory.messageRenderer != nil,
isWindowVisible: isWindowVisible,
startAction: startAction,
deliveredStatusText: viewFactory.theme.chat.visitorMessage.delivered,
deliveredStatusText: viewFactory.theme.chat.visitorMessageStyle.delivered,
chatType: chatType,
environment: Self.enviromentForChatModel(environment: environment, viewFactory: viewFactory)
)
Expand Down
4 changes: 2 additions & 2 deletions GliaWidgets/Sources/Extensions/UIColor+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extension UIColor {
let hex: String = hex.trimmingCharacters(in: Self.trimmingCharacters)
let scanner = Scanner(string: hex)

var color: UInt32 = 0
scanner.scanHexInt32(&color)
var color: UInt64 = 0
scanner.scanHexInt64(&color)

let mask = 0x000000FF
let r = CGFloat(Int(color >> 16) & mask) / 255.0
Expand Down
6 changes: 3 additions & 3 deletions GliaWidgets/Sources/Theme/Chat/Theme.ChoiceCardStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension Theme.ChoiceCardStyle {
textFont: choiceOption.normal.title.font,
textColor: UIColor(hex: choiceOption.normal.title.color),
textStyle: choiceOption.normal.title.textStyle,
backgroundColor: choiceOption.normal.background.color ?? .clear,
backgroundColor: choiceOption.normal.background.color,
borderColor: UIColor(hex: choiceOption.normal.borderColor ?? ""),
borderWidth: choiceOption.normal.borderWidth,
accessibility: .init(
Expand All @@ -164,7 +164,7 @@ extension Theme.ChoiceCardStyle {
textFont: choiceOption.selected.title.font,
textColor: UIColor(hex: choiceOption.selected.title.color),
textStyle: choiceOption.selected.title.textStyle,
backgroundColor: choiceOption.selected.background.color ?? .clear,
backgroundColor: choiceOption.selected.background.color,
borderColor: UIColor(hex: choiceOption.selected.borderColor ?? ""),
borderWidth: choiceOption.selected.borderWidth,
accessibility: .init(
Expand All @@ -176,7 +176,7 @@ extension Theme.ChoiceCardStyle {
textFont: choiceOption.disabled.title.font,
textColor: UIColor(hex: choiceOption.disabled.title.color),
textStyle: choiceOption.disabled.title.textStyle,
backgroundColor: choiceOption.disabled.background.color ?? .clear,
backgroundColor: choiceOption.disabled.background.color,
borderColor: UIColor(hex: choiceOption.disabled.borderColor ?? ""),
borderWidth: choiceOption.disabled.borderWidth,
accessibility: .init(
Expand Down
1 change: 0 additions & 1 deletion GliaWidgets/Sources/UIKitBased/UIKitBased.Interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ enum UIKitBased {
var preferredContentSizeCategory: () -> UIContentSizeCategory
var isIdleTimerDisabled: (Bool) -> Void
var windows: () -> [UIKit.UIWindow]
var statusBarOrientation: () -> UIInterfaceOrientation
}

struct UIDevice {
Expand Down
3 changes: 1 addition & 2 deletions GliaWidgets/Sources/UIKitBased/UIKitBased.Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ extension UIKitBased.UIApplication {
canOpenURL: UIApplication.shared.canOpenURL,
preferredContentSizeCategory: { UIApplication.shared.preferredContentSizeCategory },
isIdleTimerDisabled: { UIApplication.shared.isIdleTimerDisabled = $0 },
windows: { UIApplication.shared.windows },
statusBarOrientation: { UIApplication.shared.statusBarOrientation }
windows: { UIApplication.shared.windows }
)
}

Expand Down
3 changes: 1 addition & 2 deletions GliaWidgets/Sources/UIKitBased/UIKitBased.Mock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ extension UIKitBased.UIApplication {
canOpenURL: { _ in false },
preferredContentSizeCategory: { .unspecified },
isIdleTimerDisabled: { _ in },
windows: { .init() },
statusBarOrientation: { .portrait }
windows: { .init() }
)
}

Expand Down
9 changes: 3 additions & 6 deletions GliaWidgets/Sources/View/BaseView/BaseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ import UIKit
class BaseView: UIView {

var currentOrientation: UIInterfaceOrientation {
guard
#available(iOS 13.0, *),
let orientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation
else {
return UIApplication.shared.statusBarOrientation
guard let windowScene = UIApplication.shared.windows.first?.windowScene else {
return .portrait
}

return orientation
return windowScene.interfaceOrientation
}

required init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ChatMessageView: BaseView {
accessibilityProperties: accProperties
)
appendContentViews(contentViews, animated: animated)
case let .attributedText(text, accProperties):
case let .attributedText(text, _):
let contentView = ChatTextContentView(
with: style,
contentAlignment: contentAlignment
Expand Down
2 changes: 1 addition & 1 deletion GliaWidgets/Sources/ViewModel/Chat/ChatViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ extension ChatViewModel {

extension ChatViewModel {
private func presentMediaPicker() {
let itemSelected = { (kind: AttachmentSourceItemKind) -> Void in
let itemSelected = { (kind: AttachmentSourceItemKind) in
let media = ObservableValue<MediaPickerEvent>(with: .none)
media.addObserver(self) { [weak self] event, _ in
guard let self = self else { return }
Expand Down
16 changes: 8 additions & 8 deletions GliaWidgetsTests/Sources/Glia/GliaTests+StartEngagement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension GliaTests {
}
let sdk = Glia(environment: sdkEnv)
sdk.rootCoordinator = .mock(engagementKind: .chat, screenShareHandler: .mock)
try sdk.configure(with: .mock())
try sdk.configure(with: .mock(), theme: .mock()) { _ in }

XCTAssertThrowsError(
try sdk.startEngagement(
Expand All @@ -32,7 +32,7 @@ extension GliaTests {
sdk.environment.coreSDKConfigurator.configureWithConfiguration = { _, completion in
completion(.success(()))
}
try sdk.configure(with: .mock()) {}
try sdk.configure(with: .mock(), theme: .mock()) { _ in }
sdk.environment.coreSdk.getCurrentEngagement = { .mock(source: .callVisualizer) }

XCTAssertThrowsError(
Expand Down Expand Up @@ -75,7 +75,7 @@ extension GliaTests {
}
let sdk = Glia(environment: environment)

try sdk.start(.chat, configuration: .mock(), queueID: "queueId", visitorContext: nil)
try sdk.start(.chat, configuration: .mock(), queueID: "queueId", theme: .mock())

XCTAssertTrue(sdk.isConfigured)
XCTAssertEqual(calls, [.configureWithConfiguration, .configureWithInteractor])
Expand Down Expand Up @@ -155,9 +155,9 @@ extension GliaTests {
theme.call.connect.queue.firstText = "Glia 1"
theme.chat.connect.queue.firstText = "Glia 2"

try sdk.configure(with: .mock()) {
try sdk.configure(with: .mock(), theme: .mock()) { _ in
do {
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"], theme: theme)
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"])
} catch {
XCTFail("startEngagement unexpectedly failed with error \(error), but should succeed instead.")
}
Expand Down Expand Up @@ -193,7 +193,7 @@ extension GliaTests {

let sdk = Glia(environment: environment)

try sdk.configure(with: .mock(companyName: "Glia")) {
try sdk.configure(with: .mock(companyName: "Glia"), theme: .mock()) { _ in
do {
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"])
} catch {
Expand Down Expand Up @@ -231,7 +231,7 @@ extension GliaTests {

let sdk = Glia(environment: environment)

try sdk.configure(with: .mock()) {
try sdk.configure(with: .mock(), theme: .mock()) { _ in
do {
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"])
} catch {
Expand Down Expand Up @@ -318,7 +318,7 @@ extension GliaTests {
environment.coreSdk.getCurrentEngagement = { nil }

let sdk = Glia(environment: environment)
try sdk.configure(with: .mock(), completion: {})
try sdk.configure(with: .mock(), theme: .mock()) { _ in }
try sdk.startEngagement(engagementKind: .chat, in: ["queueId"])

let configuredSdkTheme = resultingViewFactory?.theme
Expand Down
Loading

0 comments on commit 0226960

Please sign in to comment.