Skip to content

Commit

Permalink
Merge pull request #663 from Infomaniak/avatar-color
Browse files Browse the repository at this point in the history
feat: Avatar color
  • Loading branch information
PhilippeWeidmann committed Mar 29, 2023
2 parents 37390aa + abbab7a commit dd41bc4
Show file tree
Hide file tree
Showing 24 changed files with 181 additions and 30 deletions.
16 changes: 8 additions & 8 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-core-ui",
"state" : {
"revision" : "93051b3183db87262a7c53ead3b479e01f888edf",
"version" : "2.2.0"
"revision" : "0277a957e2342c21c69f3978b422ad0828fa46b6",
"version" : "2.3.0"
}
},
{
Expand Down Expand Up @@ -148,26 +148,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-core.git",
"state" : {
"revision" : "dd91f5f967c4ae89c37e24ab2a0315c31106648f",
"version" : "13.6.0"
"revision" : "3c950f43bafc4fe39ce605e913cc7f30426e1747",
"version" : "13.8.0"
}
},
{
"identity" : "realm-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/realm/realm-swift",
"state" : {
"revision" : "8ac6fe1aa5d0fb0100062d80863416a4d70de8ca",
"version" : "10.37.0"
"revision" : "21b1c2844965ba5e3a0d80c43358d5ea08d934c6",
"version" : "10.37.1"
}
},
{
"identity" : "sentry-cocoa",
"kind" : "remoteSourceControl",
"location" : "https://github.com/getsentry/sentry-cocoa",
"state" : {
"revision" : "2e7899aff930ed3b8d81be1909492f7684bbd481",
"version" : "8.3.1"
"revision" : "ac224c437a3070ffe34460137ac8761eddaf2852",
"version" : "8.3.3"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Mail/Components/ThreadCellDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct ThreadCellDetailsView: View {
if thread.flagged {
MailResourcesAsset.starFull.swiftUIImage
.resizable()
.foregroundColor(MailResourcesAsset.yellowActionColor)
.foregroundColor(MailResourcesAsset.yellowColor)
.scaledToFit()
.frame(width: 16, height: 16)
}
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Alerts/CreateFolderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct CreateFolderView: View {
.padding(12)
.overlay(
RoundedRectangle(cornerRadius: 4)
.stroke(error == nil ? MailResourcesAsset.textFieldBorder.swiftUIColor : MailResourcesAsset.redActionColor.swiftUIColor)
.stroke(error == nil ? MailResourcesAsset.textFieldBorder.swiftUIColor : MailResourcesAsset.redColor.swiftUIColor)
.animation(.easeInOut, value: error)
)
.textStyle(.body)
Expand Down
4 changes: 2 additions & 2 deletions Mail/Views/Bottom sheets/Actions/ActionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ struct ActionView: View {
.resizable()
.scaledToFit()
.frame(width: 21, height: 21)
.foregroundColor(action == .report ? MailResourcesAsset.princeActionColor : accentColor.primary)
.foregroundColor(action == .report ? MailResourcesAsset.princeColor : accentColor.primary)
Text(action.title)
.foregroundColor(action == .report ? MailResourcesAsset.princeActionColor : MailResourcesAsset.textPrimaryColor)
.foregroundColor(action == .report ? MailResourcesAsset.princeColor : MailResourcesAsset.textPrimaryColor)
.textStyle(.body)
.frame(maxWidth: .infinity, alignment: .leading)
}
Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread List/NoNetworkView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct NoNetworkView: View {
Text(MailResourcesStrings.Localizable.noNetwork)
.textStyle(.bodySmallWarning)
}
.foregroundColor(MailResourcesAsset.orangeActionColor)
.foregroundColor(MailResourcesAsset.orangeColor)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread/MessageHeaderSummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct MessageHeaderSummaryView: View {
.scaledToFit()
.frame(width: 22, height: 22)
}
.tint(MailResourcesAsset.redActionColor)
.tint(MailResourcesAsset.redColor)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mail/Views/Thread/ThreadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct ThreadView: View {
}
} label: {
(thread.flagged ? MailResourcesAsset.starFull : MailResourcesAsset.star).swiftUIImage
.foregroundColor(thread.flagged ? MailResourcesAsset.yellowActionColor.swiftUIColor : .accentColor)
.foregroundColor(thread.flagged ? MailResourcesAsset.yellowColor.swiftUIColor : .accentColor)
}
}
ToolbarItemGroup(placement: .bottomBar) {
Expand Down
2 changes: 1 addition & 1 deletion MailCore/Cache/AccountManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public extension InfomaniakUser {
let avatarImage = try? await ImagePipeline.shared.image(for: avatarURL).image {
return Image(uiImage: avatarImage)
} else {
let backgroundColor = UIColor.backgroundColor(from: id)
let backgroundColor = UIColor.backgroundColor(from: id, with: UIConstants.avatarColors)
let initialsImage = UIImage.getInitialsPlaceholder(
with: displayName,
size: CGSize(width: 40, height: 40),
Expand Down
2 changes: 1 addition & 1 deletion MailCore/Models/MergedContact.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MergedContact {
let colorFromHex = UIColor(hex: remoteColorHex) {
return colorFromHex
} else {
return UIColor.backgroundColor(from: email.hash)
return UIColor.backgroundColor(from: email.hash, with: UIConstants.avatarColors)
}
}()

Expand Down
2 changes: 1 addition & 1 deletion MailCore/Models/Recipient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class Recipient: EmbeddedObject, Codable {
}()

public var color: UIColor {
return contact?.color ?? UIColor.backgroundColor(from: email.hash)
return contact?.color ?? UIColor.backgroundColor(from: email.hash, with: UIConstants.avatarColors)
}

public lazy var initials: String = {
Expand Down
37 changes: 37 additions & 0 deletions MailCore/UI/UIConstants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Infomaniak Mail - iOS App
Copyright (C) 2022 Infomaniak Network SA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import Foundation
import MailResources
import UIKit

public enum UIConstants {
public static let avatarColors = [
MailResourcesAsset.yellowColor,
MailResourcesAsset.coralColor,
MailResourcesAsset.grassColor,
MailResourcesAsset.fougereColor,
MailResourcesAsset.cobaltColor,
MailResourcesAsset.jeanColor,
MailResourcesAsset.tropicalColor,
MailResourcesAsset.mauveColor,
MailResourcesAsset.princeColor
].map(\.color)

// TODO: Move the UI constants to this file
}
10 changes: 5 additions & 5 deletions MailCore/Utils/MailTextStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct MailTextStyle {

public static let header2Error = MailTextStyle(
font: .system(size: 18, weight: .semibold),
color: MailResourcesAsset.redActionColor
color: MailResourcesAsset.redColor
)

public static let bodyMedium = MailTextStyle(
Expand All @@ -92,7 +92,7 @@ public struct MailTextStyle {

public static let bodyMediumError = MailTextStyle(
font: .system(size: 16, weight: .medium),
color: MailResourcesAsset.redActionColor
color: MailResourcesAsset.redColor
)

public static let body = MailTextStyle(
Expand All @@ -112,7 +112,7 @@ public struct MailTextStyle {

public static let bodyError = MailTextStyle(
font: .system(size: 16),
color: MailResourcesAsset.redActionColor
color: MailResourcesAsset.redColor
)

public static let bodySmallMedium = MailTextStyle(
Expand Down Expand Up @@ -152,7 +152,7 @@ public struct MailTextStyle {

public static let bodySmallWarning = MailTextStyle(
font: .system(size: 14),
color: MailResourcesAsset.orangeActionColor
color: MailResourcesAsset.orangeColor
)

public static let labelMediumAccent = MailTextStyle(
Expand All @@ -172,6 +172,6 @@ public struct MailTextStyle {

public static let labelError = MailTextStyle(
font: .system(size: 12),
color: MailResourcesAsset.redActionColor
color: MailResourcesAsset.redColor
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xB7",
"red" : "0x4C"
"blue" : "0x0B",
"green" : "0x54",
"red" : "0xFF"
}
},
"idiom" : "universal"
Expand All @@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xDA",
"red" : "0xA3"
"blue" : "0x59",
"green" : "0x94",
"red" : "0xFD"
}
},
"idiom" : "universal"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x50",
"green" : "0xAF",
"red" : "0x4B"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x93",
"green" : "0xD0",
"red" : "0x90"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF3",
"green" : "0x96",
"red" : "0x21"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xF8",
"green" : "0xC4",
"red" : "0x81"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xD4",
"green" : "0xBC",
"red" : "0x00"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xEA",
"green" : "0xDE",
"red" : "0x86"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let project = Project(name: "Mail",
.package(url: "https://github.com/Infomaniak/ios-login", .upToNextMajor(from: "4.0.0")),
.package(url: "https://github.com/Infomaniak/ios-dependency-injection", .upToNextMajor(from: "1.1.6")),
.package(url: "https://github.com/Infomaniak/ios-core", .revision("1e462dc93f8fba7fb3fb9d7b6106e23fab7b62c5")),
.package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "2.0.2")),
.package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "2.3.0")),
.package(url: "https://github.com/Infomaniak/ios-notifications", .upToNextMajor(from: "2.0.1")),
.package(url: "https://github.com/Infomaniak/ios-create-account", .upToNextMajor(from: "1.1.0")),
.package(url: "https://github.com/Infomaniak/ios-bug-tracker", .upToNextMajor(from: "2.0.0")),
Expand Down

0 comments on commit dd41bc4

Please sign in to comment.