Skip to content

Commit

Permalink
Refactored CENotification to use delegated inits.
Browse files Browse the repository at this point in the history
  • Loading branch information
austincondiff committed Feb 19, 2025
1 parent dc33a4e commit 4815194
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions CodeEdit/Features/Notifications/Models/CENotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@ struct CENotification: Identifiable, Equatable {
isSticky: Bool = false,
isRead: Bool = false
) {
self.id = id
self.icon = .symbol(name: iconSymbol, color: iconColor)
self.title = title
self.description = description
self.actionButtonTitle = actionButtonTitle
self.action = action
self.isSticky = isSticky
self.isRead = isRead
self.timestamp = Date()
self.init(
id: id,
icon: .symbol(name: iconSymbol, color: iconColor),
title: title,
description: description,
actionButtonTitle: actionButtonTitle,
action: action,
isSticky: isSticky,
isRead: isRead
)
}

init(
Expand All @@ -60,15 +61,16 @@ struct CENotification: Identifiable, Equatable {
isSticky: Bool = false,
isRead: Bool = false
) {
self.id = id
self.icon = .text(iconText, backgroundColor: iconColor, textColor: iconTextColor)
self.title = title
self.description = description
self.actionButtonTitle = actionButtonTitle
self.action = action
self.isSticky = isSticky
self.isRead = isRead
self.timestamp = Date()
self.init(
id: id,
icon: .text(iconText, backgroundColor: iconColor, textColor: iconTextColor),
title: title,
description: description,
actionButtonTitle: actionButtonTitle,
action: action,
isSticky: isSticky,
isRead: isRead
)
}

init(
Expand All @@ -80,9 +82,31 @@ struct CENotification: Identifiable, Equatable {
action: @escaping () -> Void,
isSticky: Bool = false,
isRead: Bool = false
) {
self.init(
id: id,
icon: .image(iconImage),
title: title,
description: description,
actionButtonTitle: actionButtonTitle,
action: action,
isSticky: isSticky,
isRead: isRead
)
}

private init(
id: UUID,
icon: IconType,
title: String,
description: String,
actionButtonTitle: String,
action: @escaping () -> Void,
isSticky: Bool,
isRead: Bool
) {
self.id = id
self.icon = .image(iconImage)
self.icon = icon
self.title = title
self.description = description
self.actionButtonTitle = actionButtonTitle
Expand Down

0 comments on commit 4815194

Please sign in to comment.