Skip to content

Commit

Permalink
🐛 (GEK): Emoji/SFSymbols - add dynamic background for darkmode
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Feb 23, 2024
1 parent ce6002c commit 0d5d0e2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ChoiceEmojiView: View {
@ViewBuilder
var circle: some View {
Circle()
.fill(.white)
.fill(self.choiceBackgroundColor)
.overlay {
if self.emoji.count == 1, self.emoji.containsOnlyEmojis() {
Text(self.emoji)
Expand Down Expand Up @@ -113,6 +113,11 @@ struct ChoiceEmojiView: View {

// MARK: Private

private let choiceBackgroundColor: Color = .init(
light: .white,
dark: UIColor(displayP3Red: 242 / 255, green: 242 / 255, blue: 247 / 255, alpha: 1.0)
)

private let emoji: String
private let size: CGFloat
private let state: GameplayChoiceState
Expand All @@ -123,19 +128,19 @@ struct ChoiceEmojiView: View {
}

#Preview {
VStack(spacing: 30) {
VStack(spacing: 40) {
HStack(spacing: 50) {
ChoiceEmojiView(emoji: "🍉", size: 200)
ChoiceEmojiView(emoji: "🍏", size: 200)
}

HStack(spacing: 50) {
HStack(spacing: 40) {
ChoiceEmojiView(emoji: "🌨️", size: 200)
ChoiceEmojiView(emoji: "🌧️", size: 200, state: .rightAnswer)
ChoiceEmojiView(emoji: "☀️", size: 200, state: .wrongAnswer)
}

HStack(spacing: 0) {
HStack(spacing: 40) {
ChoiceEmojiView(emoji: "🐱", size: 200)
ChoiceEmojiView(emoji: "🐶", size: 200)
ChoiceEmojiView(emoji: "🐹🐹", size: 200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ struct ChoiceSFSymbolView: View {
@ViewBuilder
var circle: some View {
Circle()
.fill(.white)
.fill(self.choiceBackgroundColor)
.overlay {
if let uiImage = UIImage(systemName: self.sfsymbol) {
if UIImage(systemName: self.sfsymbol) != nil {
Image(systemName: self.sfsymbol)
.resizable()
.scaledToFit()
Expand All @@ -40,6 +40,7 @@ struct ChoiceSFSymbolView: View {
}
}
}
.foregroundStyle(.black)
.frame(
width: self.size,
height: self.size
Expand Down Expand Up @@ -91,6 +92,11 @@ struct ChoiceSFSymbolView: View {

// MARK: Private

private let choiceBackgroundColor: Color = .init(
light: .white,
dark: UIColor(displayP3Red: 242 / 255, green: 242 / 255, blue: 247 / 255, alpha: 1.0)
)

private let sfsymbol: String
private let size: CGFloat
private let state: GameplayChoiceState
Expand All @@ -102,22 +108,23 @@ struct ChoiceSFSymbolView: View {

#Preview {
VStack(spacing: 30) {
HStack(spacing: 50) {
HStack(spacing: 40) {
ChoiceSFSymbolView(image: "airplane", size: 200)
ChoiceSFSymbolView(image: "paperplane", size: 200)
}

HStack(spacing: 50) {
HStack(spacing: 40) {
ChoiceSFSymbolView(image: "sunrise", size: 200)
ChoiceSFSymbolView(image: "sparkles", size: 200, state: .rightAnswer)
ChoiceSFSymbolView(image: "cloud.drizzle", size: 200, state: .wrongAnswer)
}

HStack(spacing: 0) {
HStack(spacing: 40) {
ChoiceSFSymbolView(image: "cat", size: 200)
ChoiceSFSymbolView(image: "fish", size: 200)
ChoiceSFSymbolView(image: "carrot", size: 200)
ChoiceSFSymbolView(image: "not_a_real_sumbol", size: 200)
}
}
.background(.lkBackground)
}

0 comments on commit 0d5d0e2

Please sign in to comment.