IceCubesApp/Packages/Env/Sources/Env/StatusAction.swift
Gareth Simpson 9ebe0b314c
Change arrows icon to rocket for boosts (#1099)
* Change arrows icon to rocket for boosts

* Fixing case (part 1)

* Fixing Case (part 2)

* Clean up after merge

* Fix for disabled boost

* Fixes

---------

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
2023-02-28 14:53:31 +01:00

72 lines
2.1 KiB
Swift

import SwiftUI
public enum StatusAction: String, CaseIterable, Identifiable {
public var id: String {
"\(rawValue)"
}
case none, reply, boost, favorite, bookmark, quote
public func displayName(isReblogged: Bool = false, isFavorited: Bool = false, isBookmarked: Bool = false, privateBoost: Bool = false) -> LocalizedStringKey {
switch self {
case .none:
return "settings.swipeactions.status.action.none"
case .reply:
return "settings.swipeactions.status.action.reply"
case .quote:
return "settings.swipeactions.status.action.quote"
case .boost:
if privateBoost {
return isReblogged ? "status.action.unboost" : "status.action.boost-to-followers"
}
return isReblogged ? "status.action.unboost" : "settings.swipeactions.status.action.boost"
case .favorite:
return isFavorited ? "status.action.unfavorite" : "settings.swipeactions.status.action.favorite"
case .bookmark:
return isBookmarked ? "status.action.unbookmark" : "settings.swipeactions.status.action.bookmark"
}
}
public func iconName(isReblogged: Bool = false, isFavorited: Bool = false, isBookmarked: Bool = false, privateBoost: Bool = false) -> String {
switch self {
case .none:
return "slash.circle"
case .reply:
return "arrowshape.turn.up.left"
case .quote:
return "quote.bubble"
case .boost:
if privateBoost {
return isReblogged ? "Rocket.Fill" : "lock.rotation"
}
return isReblogged ? "Rocket.Fill" : "Rocket"
case .favorite:
return isFavorited ? "star.fill" : "star"
case .bookmark:
return isBookmarked ? "bookmark.fill" : "bookmark"
}
}
public func color(themeTintColor: Color, useThemeColor: Bool, outside: Bool) -> Color {
if useThemeColor {
return outside ? themeTintColor : .gray
}
switch self {
case .none:
return .gray
case .reply:
return outside ? .gray : Color(white: 0.45)
case .quote:
return outside ? .gray : Color(white: 0.45)
case .boost:
return themeTintColor
case .favorite:
return .yellow
case .bookmark:
return .pink
}
}
}