Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/code updates #44

Merged
merged 8 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's.
members of the project's leadership.

## Attribution

Expand Down
616 changes: 308 additions & 308 deletions Example/Pods/Pods.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions Example/Sentinel/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private extension AppDelegate {
ToolTable(
name: "Color Change Tool",
sections: [
.init(title: "Color change", items: [.custom(ColorChangeToolTableItem())])
ToolTableSection(title: "Color change", items: [.custom(ColorChangeToolTableItem())])
]
)
}
Expand All @@ -72,21 +72,27 @@ private extension AppDelegate {
.init(
title: "UserDefaults flags",
items: [
.toggle(ToggleToolItem(
title: "Analytics",
userDefaults: .standard,
userDefaultsKey: "com.infinum.sentinel.optionSwitch.analytics"
)),
.toggle(ToggleToolItem(
title: "Crashlytics",
setter: { AppSwitches.crashlyticsEnabled = $0 },
getter: { AppSwitches.crashlyticsEnabled }
)),
.toggle(ToggleToolItem(
title: "Logging",
userDefaults: .standard,
userDefaultsKey: "com.infinum.sentinel.optionSwitch.logging"
))
.toggle(
ToggleToolItem(
title: "Analytics",
userDefaults: .standard,
userDefaultsKey: "com.infinum.sentinel.optionSwitch.analytics"
)
),
.toggle(
ToggleToolItem(
title: "Crashlytics",
setter: { AppSwitches.crashlyticsEnabled = $0 },
getter: { AppSwitches.crashlyticsEnabled }
)
),
.toggle(
ToggleToolItem(
title: "Logging",
userDefaults: .standard,
userDefaultsKey: "com.infinum.sentinel.optionSwitch.logging"
)
)
]
)

Expand Down
8 changes: 4 additions & 4 deletions Sentinel/Classes/Core/Internal/ApplicationTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import SwiftUI
/// Tool which shows Plist information about the App
struct ApplicationTool: Tool {

// MARK: - Public properties -
// MARK: - Public properties

public var name: String { tool.name }

// MARK: - Lifecycle -
// MARK: - Lifecycle

public init() {}

// MARK: - Private properties -
// MARK: - Private properties

private let tool = CustomInfoTool(
name: "Application",
Expand All @@ -45,7 +45,7 @@ struct ApplicationTool: Tool {
)
}

// MARK: - Extensions -
// MARK: - Extensions

// MARK: - UI

Expand Down
5 changes: 2 additions & 3 deletions Sentinel/Classes/Core/Internal/DeviceTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Zvonimir Medak on 30.09.2021..
//

import Foundation
import SwiftUI

/// Tool which shows current device information
Expand All @@ -15,11 +14,11 @@ struct DeviceTool: Tool {

public var name: String { tool.name }

// MARK: - Lifecycle -
// MARK: - Lifecycle

public init() {}

// MARK: - Private properties -
// MARK: - Private properties

private let tool = CustomInfoTool(
name: "Device",
Expand Down
1 change: 0 additions & 1 deletion Sentinel/Classes/Core/Internal/Image+Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Created by Zvonimir Medak on 10.12.2024..
//

import UIKit
import SwiftUI

// There's an issue with the generated assets, and local cocoapods which should be resolved in Xcode 16.1
Expand Down
2 changes: 1 addition & 1 deletion Sentinel/Classes/Core/Internal/SentinelListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct SentinelListView: View {
let items: [ToolTableSection]

var body: some View {
List(items, id: \.title) { section in
List(items, id: \.id) { section in
Section {
if let title = section.title {
Text(title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import Foundation

final class PerformanceInfoViewModel: ObservableObject {

// MARK: - Internal properties -
// MARK: - Internal properties

@Published var value: String
let item: PerformanceInfoItem

// MARK: - Private properties -
// MARK: - Private properties

private var timer: Timer?

// MARK: - Init -
// MARK: - Init

init(item: PerformanceInfoItem) {
self.item = item
Expand Down
5 changes: 5 additions & 0 deletions Sentinel/Classes/Core/ToolTable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public struct ToolTable: Tool {
self.name = name
self.sections = sections
}

public init(name: String, items: [ToolTableItem]) {
self.name = name
self.sections = [ToolTableSection(items: items)]
}
}

// MARK: - Extensions -
Expand Down
11 changes: 11 additions & 0 deletions Sentinel/Classes/Core/ToolTableSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,14 @@ public struct ToolTableSection {
self.items = items
}
}

// MARK: - Extensions -

// MARK: - Identifiable conformance

extension ToolTableSection: Identifiable {

public var id: String {
title ?? UUID().uuidString
}
}
39 changes: 26 additions & 13 deletions Sentinel/Classes/EmailSender/EmailSenderTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public enum EmailSenderUnavailableError: Error {
/// Tool which gives you the ability to easily integrate email sending with the MessageUI
public struct EmailSenderTool: Tool {

// MARK: - Public properties -
// MARK: - Public properties

public var name: String

// MARK: - Private properties -
// MARK: - Private properties

private let getter: () -> (MailData)

Expand Down Expand Up @@ -79,17 +79,30 @@ public extension EmailSenderTool {
if EmailSenderView.canSendEmail() {
EmailSenderView(mailData: getter())
} else {
VStack(spacing: 10) {
Text(alertTitle)
.font(.system(size: 17, weight: .bold))
.multilineTextAlignment(.center)

Text(alertMessage)
.font(.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
}
.frame(maxHeight: .infinity, alignment: .top)
.padding()
ErrorView(alertTitle: alertTitle, alertMessage: alertMessage)
}
}

}

// MARK: - ErrorView

private struct ErrorView: View {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend putting this into a new file and make it internal (no need to add that modifier explicitly), but to make it visible to internal implementation (e..g, if needed in other modules).


let alertTitle: String
let alertMessage: String

var body: some View {
VStack(spacing: 10) {
Text(alertTitle)
.font(.system(size: 17, weight: .bold))
.multilineTextAlignment(.center)

Text(alertMessage)
.font(.system(size: 14, weight: .regular))
.multilineTextAlignment(.center)
}
.frame(maxHeight: .infinity, alignment: .top)
.padding()
}
}
4 changes: 2 additions & 2 deletions Sentinel/Classes/TextEditing/TextEditingToolViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Foundation

final class TextEditingToolViewModel: ObservableObject {

// MARK: - Internal properties -
// MARK: - Internal properties

@Published var value: String
let title: String
let didPressSave: (String) -> Void

// MARK: - Init -
// MARK: - Init

init(value: String, title: String, didPressSave: @escaping (String) -> Void) {
self.value = value
Expand Down
4 changes: 2 additions & 2 deletions Sentinel/Classes/UserDefaults/UserDefaultsToolViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import Foundation

final class UserDefaultsToolViewModel: ObservableObject {

// MARK: - Internal properties -
// MARK: - Internal properties

let value: String
let title: String
let userDefaults: UserDefaults

// MARK: - Init -
// MARK: - Init

init(value: String, title: String, userDefaults: UserDefaults = .standard) {
self.value = value
Expand Down