diff --git a/Airship/AirshipMessageCenter/Source/Model/MessageCenterUtils.swift b/Airship/AirshipMessageCenter/Source/Model/MessageCenterUtils.swift index 512bcf6bc..b3d8a1e15 100644 --- a/Airship/AirshipMessageCenter/Source/Model/MessageCenterUtils.swift +++ b/Airship/AirshipMessageCenter/Source/Model/MessageCenterUtils.swift @@ -16,14 +16,3 @@ extension ProgressView { } } } - -extension Color { - func adaptiveColor(for colorScheme: ColorScheme, darkVariation: Color?) -> Color? { - if colorScheme == .light { - return self - } else { - /// If user doesn't provide a dark variation, fall back to the named color variation if it exists - return darkVariation ?? self - } - } -} diff --git a/Airship/AirshipMessageCenter/Source/Views/MessageCenterListItemView.swift b/Airship/AirshipMessageCenter/Source/Views/MessageCenterListItemView.swift index 39ea50ca9..031bb903f 100644 --- a/Airship/AirshipMessageCenter/Source/Views/MessageCenterListItemView.swift +++ b/Airship/AirshipMessageCenter/Source/Views/MessageCenterListItemView.swift @@ -139,7 +139,7 @@ private struct MessageCenterListContentView: View { @ViewBuilder func makeUnreadIndicator() -> some View { - let foregroundColor = theme.unreadIndicatorColor?.adaptiveColor(for: colorScheme, darkVariation: theme.unreadIndicatorColorDark) ?? theme.cellTintColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellTintColorDark) + let foregroundColor = colorScheme.resolveColor(light: theme.unreadIndicatorColor, dark: theme.unreadIndicatorColorDark) ?? colorScheme.resolveColor(light: theme.cellTintColor, dark: theme.cellTintColorDark) if self.message.unread { Image(systemName: MessageCenterListContentView.unreadIndicatorImageName) @@ -158,7 +158,7 @@ private struct MessageCenterListContentView: View { VStack(alignment: .leading, spacing: 5) { Text(self.message.title) .font(theme.cellTitleFont) - .foregroundColor(theme.cellTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.cellTitleColor, dark: theme.cellTitleColorDark)) .accessibilityHidden(true) if let subtitle = self.message.subtitle { @@ -170,7 +170,7 @@ private struct MessageCenterListContentView: View { Text(self.message.sentDate, style: .date) .font(theme.cellDateFont) - .foregroundColor(theme.cellDateColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellDateColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.cellDateColor, dark: theme.cellDateColorDark)) .accessibilityHidden(true) } } diff --git a/Airship/AirshipMessageCenter/Source/Views/MessageCenterListView.swift b/Airship/AirshipMessageCenter/Source/Views/MessageCenterListView.swift index 3ca6c40ae..f89577579 100644 --- a/Airship/AirshipMessageCenter/Source/Views/MessageCenterListView.swift +++ b/Airship/AirshipMessageCenter/Source/Views/MessageCenterListView.swift @@ -92,14 +92,14 @@ public struct MessageCenterListView: View { ) if #available(iOS 15.0, *) { - cell.listRowBackground(theme.cellColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellColorDark)) + cell.listRowBackground(colorScheme.resolveColor(light: theme.cellColor, dark: theme.cellColorDark)) .listRowSeparator( (theme.cellSeparatorStyle == SeparatorStyle.none) ? .hidden : .automatic ) - .listRowSeparatorTint(theme.cellSeparatorColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellSeparatorColorDark)) + .listRowSeparatorTint(colorScheme.resolveColor(light: theme.cellSeparatorColor, dark: theme.cellSeparatorColorDark)) } else { - cell.listRowBackground(theme.cellColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cellColorDark)) + cell.listRowBackground(colorScheme.resolveColor(light: theme.cellColor, dark: theme.cellColorDark)) } } @@ -149,12 +149,7 @@ public struct MessageCenterListView: View { @ViewBuilder private func makeContent() -> some View { - let listBackgroundColor = theme - .messageListBackgroundColor? - .adaptiveColor( - for: colorScheme, - darkVariation: theme.messageListBackgroundColorDark - ) + let listBackgroundColor = colorScheme.resolveColor(light: theme.messageListBackgroundColor, dark: theme.messageListBackgroundColorDark) let content = ZStack { makeList() @@ -214,10 +209,10 @@ public struct MessageCenterListView: View { Text( "\("ua_delete_messages".messageCenterLocalizedString) (\(self.selection.count))" ) - .foregroundColor(theme.deleteButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.deleteButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.deleteButtonTitleColor, dark: theme.deleteButtonTitleColorDark)) } else { Text("ua_delete_messages".messageCenterLocalizedString) - .foregroundColor(theme.deleteButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.deleteButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.deleteButtonTitleColor, dark: theme.deleteButtonTitleColorDark)) } } ) @@ -236,10 +231,10 @@ public struct MessageCenterListView: View { Text( "\("ua_mark_messages_read".messageCenterLocalizedString) (\(self.selection.count))" ) - .foregroundColor(theme.markAsReadButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.markAsReadButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.markAsReadButtonTitleColor, dark: theme.markAsReadButtonTitleColorDark)) } else { Text("ua_mark_messages_read".messageCenterLocalizedString) - .foregroundColor(theme.markAsReadButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.markAsReadButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.markAsReadButtonTitleColor, dark: theme.markAsReadButtonTitleColorDark)) } } ) @@ -261,7 +256,7 @@ public struct MessageCenterListView: View { self.selection = Set(self.messageIDs) } label: { Text("ua_select_all_messages".messageCenterLocalizedString) - .foregroundColor(theme.selectAllButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.selectAllButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.selectAllButtonTitleColor, dark: theme.selectAllButtonTitleColorDark)) } .accessibilityHint("ua_select_all_messages".messageCenterLocalizedString) } @@ -271,7 +266,7 @@ public struct MessageCenterListView: View { self.selection = Set() } label: { Text("ua_select_none_messages".messageCenterLocalizedString) - .foregroundColor(theme.selectAllButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.selectAllButtonTitleColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.selectAllButtonTitleColor, dark: theme.selectAllButtonTitleColorDark)) } .accessibilityHint("ua_select_none_messages".messageCenterLocalizedString) } @@ -294,8 +289,8 @@ public struct MessageCenterListView: View { let isEditMode = self.editMode?.wrappedValue.isEditing ?? false let color = isEditMode - ? theme.cancelButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.cancelButtonTitleColorDark) : - theme.editButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.editButtonTitleColorDark) + ? colorScheme.resolveColor(light: theme.cancelButtonTitleColor, dark: theme.cancelButtonTitleColorDark) : + colorScheme.resolveColor(light: theme.editButtonTitleColor, dark: theme.editButtonTitleColorDark) return EditButton() .foregroundColor(color) @@ -304,7 +299,7 @@ public struct MessageCenterListView: View { @ViewBuilder private func refreshButton() -> some View { - let refreshColor = theme.refreshTintColor?.adaptiveColor(for: colorScheme, darkVariation: theme.refreshTintColorDark) + let refreshColor = colorScheme.resolveColor(light: theme.refreshTintColor, dark: theme.refreshTintColorDark) if isRefreshing { ProgressView() diff --git a/Airship/AirshipMessageCenter/Source/Views/MessageCenterMessageView.swift b/Airship/AirshipMessageCenter/Source/Views/MessageCenterMessageView.swift index e9ea28365..c7febe4e6 100644 --- a/Airship/AirshipMessageCenter/Source/Views/MessageCenterMessageView.swift +++ b/Airship/AirshipMessageCenter/Source/Views/MessageCenterMessageView.swift @@ -461,7 +461,7 @@ private struct MessageCenterMessageContentView: View { ) } dismiss() - }.foregroundColor(theme.deleteButtonTitleColor?.adaptiveColor(for: colorScheme, darkVariation: theme.deleteButtonTitleColorDark)) + }.foregroundColor(colorScheme.resolveColor(light: theme.deleteButtonTitleColor, dark: theme.deleteButtonTitleColorDark)) } } @@ -473,7 +473,7 @@ private struct MessageCenterMessageContentView: View { Image(systemName: "chevron.backward") .scaleEffect(0.68) .font(Font.title.weight(.medium)) - .foregroundColor(theme.backButtonColor?.adaptiveColor(for: colorScheme, darkVariation: theme.backButtonColorDark)) + .foregroundColor(colorScheme.resolveColor(light: theme.backButtonColor, dark: theme.backButtonColorDark)) } } diff --git a/Airship/AirshipMessageCenter/Source/Views/MessageCenterView.swift b/Airship/AirshipMessageCenter/Source/Views/MessageCenterView.swift index 113a775a2..51d4fece5 100644 --- a/Airship/AirshipMessageCenter/Source/Views/MessageCenterView.swift +++ b/Airship/AirshipMessageCenter/Source/Views/MessageCenterView.swift @@ -118,7 +118,7 @@ internal struct DefaultMessageCenterViewStyle: MessageCenterViewStyle { @ViewBuilder internal func makeBody(configuration: Configuration) -> some View { - let containerBackgroundColor: Color? = configuration.theme.messageListContainerBackgroundColor?.adaptiveColor(for: configuration.colorScheme, darkVariation: configuration.theme.messageListContainerBackgroundColorDark) + let containerBackgroundColor: Color? = configuration.colorScheme.resolveColor(light: configuration.theme.messageListContainerBackgroundColor, dark: configuration.theme.messageListContainerBackgroundColorDark) let content = configuration.content .applyIf(containerBackgroundColor != nil) { view in