Skip to content
New issue

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

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

Already on GitHub? # to your account

[PBIOS-566] Fix Online Status Color #449

Merged
merged 17 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
35 changes: 32 additions & 3 deletions Sources/Playbook/Components/Avatar/AvatarCatalog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public struct AvatarCatalog: View {
PBDoc(title: "Status Size") {
statusSize
}
PBDoc(title: "Status color") {
statusColor
}
}
}
}
Expand Down Expand Up @@ -50,9 +53,35 @@ extension AvatarCatalog {

var statusSize: some View {
VStack(alignment: .leading, spacing: Spacing.small) {
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .online, statusSize: .small)
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .away, statusSize: .medium)
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .offline, statusSize: .large)
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .small, status: .online, statusSize: .medium)
Text("Small").pbFont(.caption)
}
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .away, statusSize: .medium)
Text("Medium").pbFont(.caption)
}
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .large, status: .offline, statusSize: .medium)
Text("Large").pbFont(.caption)
}
}
}

var statusColor: some View {
VStack(alignment: .leading, spacing: Spacing.small) {
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .online, statusSize: .medium)
Text("Online").pbFont(.caption)
}
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .away, statusSize: .medium)
Text("Away").pbFont(.caption)
}
VStack(spacing: Spacing.xxSmall) {
PBAvatar(image: Image("andrew", bundle: .module), size: .medium, status: .offline, statusSize: .medium)
Text("Offline").pbFont(.caption)
}
}
}
}
Expand Down
28 changes: 21 additions & 7 deletions Sources/Playbook/Components/Online Status/PBOnlineStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import SwiftUI

public struct PBOnlineStatus: View {
let status: Status
let status: Status?
let color: Color?
let size: Size
let borderColor: Color?
let variant: Variant
@Environment(\.colorScheme) var colorScheme

public init(
status: Status = .online,
status: Status? = nil,
color: Color? = nil,
size: Size = .small,
borderColor: Color? = .white,
Expand Down Expand Up @@ -56,10 +56,10 @@ public extension PBOnlineStatus {
if let color = color {
return color
} else {
switch status {
case .online: return .status(.success)
case .offline: return .status(.error)
case .away: return . status(.warning)
if let status = status {
return status.color
} else {
return .status(.neutral)
}
}
}
Expand Down Expand Up @@ -91,13 +91,27 @@ public extension PBOnlineStatus {
}

enum Status {
case online, offline, away
case away
case error
case info
case neutral
case offline
case online
case primary
case success
case warning

var color: Color {
switch self {
case .online: return .status(.success)
case .away: return .status(.warning)
case .offline: return .status(.neutral)
case .error: return .status(.error)
case .info: return .status(.info)
case .neutral: return .status(.neutral)
case .primary: return .pbPrimary
case .success: return .status(.success)
case .warning: return .status(.warning)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Playbook/Resources/Helper Files/Mocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
import SwiftUI

enum Mocks {
static let andrew = PBUser(name: "Andrew Black", nameFont: .init(font: .title4, variant: .bold), image: Image("andrew", bundle: .module), size: .small, title: "Senior User Experience Engineer")
static let andrew = PBUser(name: "Andrew Black", nameFont: .init(font: .title4, variant: .bold), image: Image("andrew", bundle: .module), size: .small, title: "Senior User Experience Engineer")
static let ana = PBUser(name: "Ana Black", nameFont: .init(font: .title4, variant: .bold), image: Image("Anna", bundle: .module), size: .small, title: "Senior User Experience Engineer")
static let patric = PBUser(name: "Pat Black", nameFont: .init(font: .title4, variant: .bold), image: Image("Pat", bundle: .module), size: .small, title: "Senior User Experience Engineer")
static let luccile = PBUser(name: "Luccile Black", nameFont: .init(font: .title4, variant: .bold), image: Image("Lu", bundle: .module), size: .small, title: "Senior User Experience Engineer")
static let oneUser = [andrew]
static let twoUsers = [andrew, ana]
static let threeUsers = [andrew, ana, patric]
static let multipleUsers = [andrew, ana, patric, luccile]
static let multipleUsersDictionary: [(String, (String, (() -> PBUser?)?)?)] = [
("1", (andrew.name, { andrew })),
("2", (ana.name, { ana })),
("3", (patric.name, { patric })),
("4", (luccile.name, { luccile }))
]
static let multipleUsersDictionary: [(String, (String, (() -> PBUser?)?)?)] = [
("1", (andrew.name, { andrew })),
("2", (ana.name, { ana })),
("3", (patric.name, { patric })),
("4", (luccile.name, { luccile }))
]
static let avatarXSmall = PBAvatar(image: Image("andrew", bundle: .module), size: .xSmall)
static let avatarXSmallStatus = PBAvatar(image: Image("andrew", bundle: .module), size: .xSmall, status: .online)
static let userName = "Andrew Black"
Expand Down